.mapError doesnt work with async
ResultAsync.from(yourpromise).mapError(e => {}) map error is not being invoked when promise is throwing.
Yes, currently ResultAsync.from() does not convert a rejected Promise into a failed Result - the Promise is expected to resolve to a Result.
The JS Doc comment states this:
/**
* Creates a new ResultAsync from the given Promise
* @param value a Promise resolving to a Result
*/
So, at the moment it is up to you to ensure your Promise handles the failure with a .catch(e => Result.failure(...))
Maybe I could make a separate ResultAsync.fromPromise() that has the functionality you are looking for?
Thanks for the answer. IDK, its counter-intuitive to do result async from a promise and have api .maperror that doesnt catch errors from this promise, also its not mentioned in the docs how to use that. So basically u have to map firslty the promise to result fialure and then map error, its not something you come up with. Actually i just stopped using monads here, just doing the .catch() explicitly without Result chain. Just mention it in the docs and youll be fine