Skip to main content

ErrorCode

Enum ErrorCode 

Source
#[repr(i32)]
pub enum ErrorCode { NotFound = 404, ToolAuthorizationRequired = 4_006, ToolAuthorizationFailed = 4_007, ProtocolVersionMismatch = 4_008, McpServerNotFound = 4_014, McpCapabilityNotSupported = 4_015, SkillNameInvalid = 4_016, SkillResourceNotAccessible = 4_017, BlobNotAccessible = 4_018, }
Expand description

A2C-SMCP 协议错误码(v0.2.0 起;v0.2.1 加性追加 4016 / 4017 / 4018)。

镜像 Python 参考实现 a2c_smcp/smcp.py::ErrorCode序列化 / 反序列化均为整数 (与协议 ErrorPayload.code 的线格式一致)。协议依据 / Protocol: error-handling.md。

⚠️ 与 error_codes 模块区分:本枚举是协议级闭集is_protocol_error_payload 识别 + client:* ack 必用);error_codes 是传输/管理层与工具/房间码。两者仅 404 重合,有意不合并。

语义要点 / Semantics:

  • ErrorCode::NotFound404):通用「资源不存在」。本 SDK 用于 client:* 路由层 目标 Computer 名未命中(error-handling.md 明确「Computer 不存在」归 404);镜像协议已有定义,非新增。
  • ErrorCode::McpServerNotFound4014):v0.2.1 复用——SKILL name 格式合法但不存在 (未注册 / 已卸载 / 孤儿)复用此码;name 格式非法 → ErrorCode::SkillNameInvalid4016); name 有效但 rel_path 不可达 → ErrorCode::SkillResourceNotAccessible4017)。
  • SKILL 通道不使用 4015:未声明 resources capability 的 server 在物化阶段即被排除,不上送 Agent。
  • 4017 / 4018details.reason开放枚举:解析方 MUST 容忍未知值并兜底 (默认「不重试 + 诊断」),未来可非破坏地新增 reason。

Mirrors the Python reference ErrorCode; serializes to / from an integer matching the protocol ErrorPayload.code wire format.

Variants§

§

NotFound = 404

通用「资源不存在」/ Generic “resource not found”(含 client:* 路由层 Computer 名未命中)。

§

ToolAuthorizationRequired = 4_006

MCP 上游要求授权 / MCP upstream requires authorization。

§

ToolAuthorizationFailed = 4_007

MCP 上游授权失败 / MCP upstream authorization failed。

§

ProtocolVersionMismatch = 4_008

协议版本不匹配(承载于 HTTP 400 body)/ Protocol version mismatch (carried in HTTP 400 body)。

⚠️ MUST NOT 与 WS close code WS_VERSION_HANDSHAKE_REJECTED_CLOSE_CODE4900)混用。

§

McpServerNotFound = 4_014

MCP Server 路由未命中 / MCP server not found(v0.2.1 复用于 SKILL name 合法但 Registry 未命中)。

§

McpCapabilityNotSupported = 4_015

MCP 能力不支持 / MCP capability not supported。

§

SkillNameInvalid = 4_016

SKILL name 违反 lexer 规则(格式硬错)/ SKILL name violates lexer rules (hard format error)。

§

SkillResourceNotAccessible = 4_017

SKILL 资源不可达 / SKILL resource not accessible(rel_path 穿越 / .skillenv forbidden / not_found / too_large)。

§

BlobNotAccessible = 4_018

二进制 blob 不可达 / Binary blob not accessible(invalid_handle / forbidden / gone / range)。

Implementations§

Source§

impl ErrorCode

Source

pub const fn code(self) -> i32

返回错误码的整数值 / Return the integer code value.

Source

pub fn from_code(code: i32) -> Option<ErrorCode>

从整数值解析错误码;未知值返回 None / Parse from an integer; unknown values return None.

Trait Implementations§

Source§

impl Clone for ErrorCode

Source§

fn clone(&self) -> ErrorCode

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<(), Error>

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

impl<'de> Deserialize<'de> for ErrorCode

Source§

fn deserialize<D>( deserializer: D, ) -> Result<ErrorCode, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Eq for ErrorCode

Source§

impl Hash for ErrorCode

Source§

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

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: &ErrorCode) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for ErrorCode

Source§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. 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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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> Same for T

Source§

type Output = T

Should always be Self
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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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