API reference / @evolu/common / Result

Result

Utilities

Type AliasDescription
InferErrExtracts the error type from a Result.
InferOkExtracts the value type from a Result.

Other

NameDescription
ErrAn error Result.
OkA successful Result.
ResultThe problem with throwing an exception in JavaScript is that the caught error is always of an unknown type. The unknown type is a problem because we can't be sure all errors have been handled because the TypeScript compiler can't tell us.
errCreates an Err result.
getOrNullExtracts the value from a Result if it is an Ok, or returns null if it is an Err.
getOrThrowExtracts the value from a Result if it is an Ok, or throws an error if it is an Err.
okCreates an Ok result.
tryAsyncWraps async functions or any operation returning a promise, returning a Result.
trySyncWraps synchronous functions that may throw exceptions, returning a Result.

Was this page helpful?