Skip to main content

ServerError

Enum ServerError 

Source
#[non_exhaustive]
pub enum ServerError {
Show 18 variants TaskNotFound(TaskId), TaskNotCancelable(TaskId), InvalidParams(String), InvalidField { field: String, message: String, }, Serialization(Error), Http(Error), HttpClient(String), Transport(String), PushNotSupported, Internal(String), Config(String), MethodNotFound(String), Protocol(A2aError), PayloadTooLarge(String), UnsupportedOperation(String), InvalidStateTransition { task_id: TaskId, from: TaskState, to: TaskState, }, Overloaded(String), Halted(String),
}
Expand description

Server framework error type.

Each variant maps to a specific A2A ErrorCode via to_a2a_error.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TaskNotFound(TaskId)

The requested task was not found.

§

TaskNotCancelable(TaskId)

The task is in a terminal state and cannot be canceled.

§

InvalidParams(String)

Invalid method parameters.

§

InvalidField

Invalid method parameters, with the field at fault: answered as InvalidParams carrying a google.rpc.BadRequest detail that names the field (spec §3.3.2: well-known error types “SHOULD be used where applicable”; audit register, the §3.3.2 row). The handler’s own request checks named the field in the message only.

Fields

§field: String

The field’s path in the request, as the JSON bindings spell it (message.parts, message.parts[0].raw).

§message: String

What is wrong with it.

§

Serialization(Error)

JSON serialization/deserialization failure.

§

Http(Error)

Hyper HTTP error.

§

HttpClient(String)

HTTP client-side error (e.g. push notification delivery).

§

Transport(String)

Transport-layer error.

§

PushNotSupported

The agent does not support push notifications.

§

Internal(String)

An internal server error.

§

Config(String)

The handler cannot be built as configured: what RequestHandlerBuilder::build refuses, saying what to change. A mistake in the deploying code, never in a request, so no caller is ever answered with it. Until 2026-10-30 these were InvalidParams, which is also the -32602 a request is refused with (audit G-11).

§

MethodNotFound(String)

The requested JSON-RPC method was not found.

§

Protocol(A2aError)

An A2A protocol error propagated from the executor.

§

PayloadTooLarge(String)

The request body exceeds the configured size limit.

§

UnsupportedOperation(String)

The operation is not supported for the current task state (e.g. sending a message to a terminal task, subscribing to a completed task).

§

InvalidStateTransition

An invalid task state transition was attempted.

Fields

§task_id: TaskId

The task ID.

§from: TaskState

The current state.

§to: TaskState

The attempted target state.

§

Overloaded(String)

The server is at a configured resource limit (e.g. the max_concurrent_streams cap) and transiently cannot accept the request. Clients should back off and retry. Maps to gRPC RESOURCE_EXHAUSTED.

§

Halted(String)

An operator halted the server, or the request’s tenant, with RequestHandler::halt; new work is refused until resume. Not transient: retrying will not help until a person resumes it. HTTP 503, gRPC UNAVAILABLE, JSON-RPC internal error.

Implementations§

Source§

impl ServerError

Source

pub const fn metric_label(&self) -> &'static str

Returns a bounded, low-cardinality discriminant for this error, suitable as a metrics/telemetry label.

This is a fixed set of variant names — never the error message, which embeds client-controlled data (task ids, sizes, URLs). Using the message as a metric label lets a caller mint an unbounded number of time series (e.g. by requesting many random task ids), exhausting the backend’s cardinality budget.

Source

pub fn to_a2a_error(&self) -> A2aError

Converts this server error into an A2aError suitable for wire responses.

§Mapping
VariantErrorCode
TaskNotFoundTaskNotFound
TaskNotCancelableTaskNotCancelable
InvalidParamsInvalidParams
SerializationParseError
MethodNotFoundMethodNotFound
PushNotSupportedPushNotificationNotSupported
UnsupportedOperationUnsupportedOperation
everything elseInternalError

Trait Implementations§

Source§

impl Debug for ServerError

Source§

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

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

impl Display for ServerError

Source§

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

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

impl Error for ServerError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Replaced by Error::source.
Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<A2aError> for ServerError

Source§

fn from(e: A2aError) -> ServerError

Converts to this type from the input type.
Source§

impl From<Error> for ServerError

Source§

fn from(e: Error) -> ServerError

Converts to this type from the input type.
Source§

impl From<Error> for ServerError

Source§

fn from(e: Error) -> ServerError

Converts to this type from the input type.

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
§

impl<'a, T, E> AsTaggedExplicit<'a, E> for T
where T: 'a,

§

fn explicit(self, class: Class, tag: u32) -> TaggedParser<'a, Explicit, Self, E>

§

impl<'a, T, E> AsTaggedImplicit<'a, E> for T
where T: 'a,

§

fn implicit( self, class: Class, constructed: bool, tag: u32, ) -> TaggedParser<'a, Implicit, Self, E>

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FutureExt for T

§

fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
§

fn with_current_context(self) -> WithContext<Self> ⓘ

Attaches the current Context to this type, returning a WithContext wrapper. Read more
§

impl<T> Instrument for T

§

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

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

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

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> IntoRequest<T> for T

§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
§

impl<L> LayerExt<L> for L

§

fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>
where L: Layer<S>,

Applies the layer to a service and wraps it in [Layered].
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

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

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