Type Alias: Result<T, E>
Result<T
, E
> = Success
<T
> | Failure
<E
>
Defined in: result.ts:68
A union type representing either a success or a failure.
Type Parameters
T
T
The type of the Success value.
E
E
The type of the Failure value.
Example
import { Result } from '@praha/byethrow';
const doSomething = (): Result.Result<number, string> => {
return Math.random() > 0.5
? { type: 'Success', value: 10 }
: { type: 'Failure', error: 'Oops' };
};