mirror of
https://github.com/logos-storage/logos-storage-js.git
synced 2026-01-26 17:23:15 +00:00
11 lines
455 B
TypeScript
11 lines
455 B
TypeScript
|
|
import { 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 }
|
||
|
|
|