mirror of
https://github.com/logos-storage/logos-storage-js.git
synced 2026-01-02 13:33:07 +00:00
12 lines
466 B
TypeScript
12 lines
466 B
TypeScript
import { type CodexError } from "../errors/errors";
|
|
|
|
/**
|
|
* SafeValue is a type used for error handling instead of throwing errors.
|
|
* It is inspired by Go's "error as value" concept.
|
|
* If the value represents an error, `error` is true and `data` will contain the error.
|
|
* If the value is not an error, `error` is false and `data` will contain the requested data.
|
|
*/
|
|
export type SafeValue<T> =
|
|
| { error: false; data: T }
|
|
| { error: true; data: CodexError };
|