mirror of
https://github.com/openclaw/openclaw.git
synced 2026-07-22 20:41:11 +00:00
* refactor(normalization-core): promote shared result type * refactor(agent-core): reuse canonical error coercion * refactor: discriminate internal operation results * docs: establish shared result convention * fix(agent-core): preserve error coercion facade * build: derive package entries from exports * fix(plugins): resolve shared result subpath * fix(ci): align Result integration guards * build: refresh plugin SDK API baseline * fix(agent-core): preserve toError compatibility
13 lines
481 B
TypeScript
13 lines
481 B
TypeScript
/** Result of a fallible operation. Expected failures use the `ok: false` arm. */
|
|
export type Result<TValue, TError> = { ok: true; value: TValue } | { ok: false; error: TError };
|
|
|
|
/** Create a successful {@link Result}. */
|
|
export function ok<TValue, TError>(value: TValue): Result<TValue, TError> {
|
|
return { ok: true, value };
|
|
}
|
|
|
|
/** Create a failed {@link Result}. */
|
|
export function err<TValue, TError>(error: TError): Result<TValue, TError> {
|
|
return { ok: false, error };
|
|
}
|