Skip to main content

ErrorCode

Enum ErrorCode 

Source
pub enum ErrorCode {
Show 40 variants InvalidInput = 1_001, MissingParameter = 1_002, Cancelled = 1_003, Timeout = 1_004, NotImplemented = 1_005, UnsupportedConfig = 1_006, ToolNotFound = 2_001, ToolValidation = 2_002, ToolExecution = 2_003, ToolSandboxed = 2_004, PermissionDenied = 3_001, PathNotAllowed = 3_002, NetworkBlocked = 3_003, HttpClientError = 4_001, HttpServerError = 4_002, ApiUnauthorized = 4_003, ApiRateLimited = 4_004, ConnectionTimeout = 4_005, ConnectionFailed = 4_006, FileNotFound = 5_001, FileReadError = 5_002, FileWriteError = 5_003, FilePermission = 5_004, InvalidPath = 5_005, DiskFull = 5_006, SessionNotFound = 6_001, SessionExpired = 6_002, SessionCapReached = 6_003, TranscriptCorrupt = 6_004, ModelUnsupportedParam = 7_001, ContextWindowExceeded = 7_002, ModelParseError = 7_003, ModelEmptyResponse = 7_004, StreamAborted = 7_005, McpConnectFailed = 8_001, McpToolCallFailed = 8_002, McpOAuthFailed = 8_003, InternalInconsistency = 9_001, ChannelClosed = 9_002, Internal = 9_999,
}
Expand description

全局错误码。

编码规则:

  • 1xxx — 通用 / 输入验证
  • 2xxx — 工具执行
  • 3xxx — 权限 / 安全
  • 4xxx — 网络 / API
  • 5xxx — 文件 / IO
  • 6xxx — 会话 / 状态
  • 7xxx — 模型 / LLM
  • 8xxx — MCP 协议
  • 9xxx — 内部 / 未分类

Variants§

§

InvalidInput = 1_001

输入格式不符合预期

§

MissingParameter = 1_002

缺少必填参数

§

Cancelled = 1_003

操作被用户取消

§

Timeout = 1_004

操作超时

§

NotImplemented = 1_005

功能未实现

§

UnsupportedConfig = 1_006

不支持的配置

§

ToolNotFound = 2_001

工具未找到

§

ToolValidation = 2_002

工具输入校验失败

§

ToolExecution = 2_003

工具执行失败

§

ToolSandboxed = 2_004

工具被沙箱拒绝

§

PermissionDenied = 3_001

权限拒绝

§

PathNotAllowed = 3_002

路径不在允许范围内

§

NetworkBlocked = 3_003

网络访问被策略阻止

§

HttpClientError = 4_001

HTTP 客户端错误 (4xx)

§

HttpServerError = 4_002

HTTP 服务端错误 (5xx)

§

ApiUnauthorized = 4_003

API 认证失败

§

ApiRateLimited = 4_004

API 限流

§

ConnectionTimeout = 4_005

连接超时

§

ConnectionFailed = 4_006

DNS / TCP 连接失败

§

FileNotFound = 5_001

文件不存在

§

FileReadError = 5_002

文件读取失败

§

FileWriteError = 5_003

文件写入失败

§

FilePermission = 5_004

文件权限不足

§

InvalidPath = 5_005

路径格式不合法

§

DiskFull = 5_006

磁盘空间不足

§

SessionNotFound = 6_001

会话不存在

§

SessionExpired = 6_002

会话已过期

§

SessionCapReached = 6_003

会话达到上限

§

TranscriptCorrupt = 6_004

JSONL 格式错误

§

ModelUnsupportedParam = 7_001

模型不支持的参数

§

ContextWindowExceeded = 7_002

token 超出上下文窗口

§

ModelParseError = 7_003

模型响应解析失败

§

ModelEmptyResponse = 7_004

模型返回空响应

§

StreamAborted = 7_005

流意外终止

§

McpConnectFailed = 8_001

MCP 服务连接失败

§

McpToolCallFailed = 8_002

MCP 工具调用失败

§

McpOAuthFailed = 8_003

MCP OAuth 流程失败

§

InternalInconsistency = 9_001

内部状态不一致

§

ChannelClosed = 9_002

channel 发送端断开

§

Internal = 9_999

未分类的内部错误

Implementations§

Source§

impl ErrorCode

Source

pub fn label(self) -> &'static str

人类可读的简短标签(英文,一行)。

Source

pub fn code(self) -> u16

错误码数值。

Trait Implementations§

Source§

impl Clone for ErrorCode

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for ErrorCode

Source§

impl Debug for ErrorCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Display for ErrorCode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for ErrorCode

Source§

impl Hash for ErrorCode

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for ErrorCode

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for ErrorCode

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more