ErrorContext
CORE · interface · 类型合同
Boundary metadata is recorded internally, without replacing the original thrown value.
导入
ts
import type { ErrorContext } from '@jangts/agent-core/errors';js
/** @typedef {import('@jangts/agent-core/errors').ErrorContext} ErrorContext */其他公开入口:@jangts/agent-core/types、@jangts/agent-core/structs、@jangts/agent-core/errors。
定义
ts
interface ErrorContext字段结构
| 字段 | 类型 | 必需 | 说明 |
|---|---|---|---|
stageId | string | undefined | 可省略 | 只读。Stage that first observed the error; later annotations keep the earliest value. |
codes | readonly string[] | undefined | 可省略 | 只读。Codes contributed by the boundary, merged with those found on the error itself. |
isRetryable | boolean | undefined | 可省略 | 只读。Retryability asserted by the boundary; omitted when it cannot be determined. |
类型使用
在调用方读取该合同
ts
import type { ErrorContext } from '@jangts/agent-core/errors';
// 在使用点保留原合同,TS 与 JS 具有相同的运行行为。
function inspect(value: ErrorContext) {
return value.stageId;
}js
/** @param {import('@jangts/agent-core/errors').ErrorContext} value */
function inspect(value) {
return value.stageId;
}