Private constructorPrivate Optional Readonly errorPrivate Readonly isPrivate Optional Readonly valuePerform an action on the embedded value, but continue with the same Try. Does not throw if the Try is a failure. If the transformer throws, the result will be a failed Try.
A function that takes the Try's value and returns nothing.
The original Try if it was a failure or the transformer succeeded, otherwise a new Try with the failure of the transformer.
Map the Try to a new Try, but flatten the result. If the Try is a failure, the new Try will be a failure.
A function that takes the Try's value and returns a new Try.
A new Try with the result of the transformer, a new Try with the error if one occured in the transformer, or the original Try if it is a failure.
Return the value embedded in the Try, or return the result of the transformer if the Try is a failure.
A function that takes the Try's error and returns a value.
The value embedded in the Try, or the result of the transformer.
Return the value embedded in the Try, or throw the result of the executor if the Try is a failure.
A function that takes the Try's error and returns an error.
The value embedded in the Try.
Map the Try to a new Try.
A function that takes the Try's value and returns a new value.
A new Try with the mapped value, a new Try with the error if one occured in the transformer, or the original Try if it is a failure.
Map the Try to a new AsyncTry with the result of the Async Transformer. If the Try is a failure, the new AsyncTry will be a failure.
An async function that takes the Try's value and returns a new value as a Promise.
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.
Map the embedded failure. Does nothing if the Try is a success.
A function that takes the Try's error and maps it to a new error.
The original Try if it is a success, or a new Try with the mapped error.
Perform an action on the Error that caused this Try to be a failure. Does nothing if the Try is a success.
A function that takes the Try's error and returns nothing.
The original Try if it was a success or the transformer succeeded, otherwise a new Try with the failure of the transformer.
Map the embedded failure to a new successful Try. Does nothing if the Try is a success. If the failureMapper throws, the result will be a failed Try.
The original Try if it is a success, or a new Try with the original failure mapped to a success.
Static failureStatic ofCreate a new Try by trying to execute the executor. If the executor throws an error, the Try will be a failure. If the executor returns a value, the Try will be successful and contain the return value of the executor.
A function that might return a value or throw an error.
A new Try with the result of the executor, or a new Try with the error if one occured in the executor.
Static successGenerated using TypeDoc
A Try is a container for a value or an error. It is used to handle exceptions in a functional way. A Try can be successful or a failure. A successful Try contains a value, while a failed Try contains an error. A Try can be mapped to a new Try, or the value can be extracted from the Try. If the Try is a failure, the error can be extracted or mapped to a new error. The Try can also be used to perform actions on the value, or to provide a default value if the Try is a failure. The Try can be used to chain operations together.
Example