Private constructorPrivate Optional errorPrivate Optional resultPrivate Optional Readonly valuePerform an action on the value of the AsyncTry, but continue with the same AsyncTry. Does not throw if the AsyncTry is a failure. If the transformer throws, the result will be a failed AsyncTry.
A function that takes the value and returns void.
A new AsyncTry with the same value if the transformer was successful, or a new AsyncTry with the error if one occured in the transformer.
Map the AsyncTry to a new AsyncTry with the result of the Async Transformer. If the AsyncTry is a failure, the new AsyncTry will be a failure.
A function that takes the AsyncTry's value and returns a new AsyncTry.
A new AsyncTry with the result of the transformer, a new AsyncTry with the error if one occured in the transformer, or a new AsyncTry with the original failure if this is a failure.
Get the value of the AsyncTry. If the AsyncTry is a failure, the Promise will be rejected with the error. It's important to know that this method will resolve the value, which means it executes all chained transformers.
A Promise containing the value of the AsyncTry if it is successful. If the AsyncTry is a failure, the Promise will be rejected with the error.
Get the value of the AsyncTry if it is successful, or the result of the alternative provider if it is a failure.
A Promise containing the value of the AsyncTry if it is successful, or the result of the alternative provider if it is a failure.
Return the value of the AsyncTry if it is successful, or throw the result of the Error transformer if it is a failure.
A function that takes the error and returns a new error.
A Promise containing the value of the AsyncTry if it is successful, or the result of the failure mapper if it is a failure.
Map the AsyncTry to a new AsyncTry.
A function that takes the AsyncTry's value and returns a new value.
A new AsyncTry with the mapped value, a new AsyncTry with the error if one occured in the transformer, or the original AsyncTry if it is a failure.
Map the failure of the AsyncTry to a new failed AsyncTry. If the AsyncTry is a success, the new AsyncTry will be the same. If the failureMapper throws, the result will be a failed AsyncTry with the error of the failureMapper.
A function that takes the error and returns a new error.
A new failed AsyncTry with the mapped error, or the original AsyncTry if it is a success.
Map the failure of the AsyncTry to a new successful AsyncTry. If the AsyncTry is a success, the new AsyncTry will be the same. If the failureMapper throws, the result will be a failed AsyncTry with the error of the failureMapper.
A new successful AsyncTry with the mapped error, or the original AsyncTry if it is a success.
Try to resolve the AsyncTry to an Either. If the AsyncTry is a failure, the Either will be of type 'Left' and contain the error. If the AsyncTry is successful, the Either will be of type 'Right' and contain the value.
A Promise containing an Either with the result of the AsyncTry.
Static failureStatic ofCreate a new AsyncTry with the result of the executor. If the executor throws, the result will be a failed AsyncTry. If the executor returns a value, the result will be a successful AsyncTry with the value.
An async function that returns a value or throws an error.
A new AsyncTry with the result of the executor, or a new failed AsyncTry with the error if one occured in the executor.
Static successGenerated using TypeDoc
An asynchronous version of the Try class. An AsyncTry is a container for a value that may or may not be present, and may or may not be an error. It is used to handle asynchronous operations that may fail. An AsyncTry can be successful or a failure. A successful AsyncTry contains a value, while a failed AsyncTry contains an error. An AsyncTry can be mapped to a new AsyncTry, or the value can be extracted from the AsyncTry. If the AsyncTry is a failure, the error can be extracted or mapped to a new error. The AsyncTry can also be used to perform actions on the value, or to provide a default value if the AsyncTry is a failure. The AsyncTry can be used to chain operations together.
Example