pub struct CoercionError {
pub message: String,
pub parameter_path: Option<String>,
pub expected_type: Option<String>,
pub received_value: Option<Value>,
pub hint: Option<String>,
}Expand description
Structured error type for coercion failures.
Provides rich error information to help AI agents understand what went wrong and how to fix it.
Fields§
§message: StringHuman-readable error message
parameter_path: Option<String>Path to the parameter that failed (e.g., “session_id”, “updates[0].interaction_type”)
expected_type: Option<String>Expected type description (e.g., “UUID string”, “one of: qa, decision_made, …”)
received_value: Option<Value>The actual value that was received
hint: Option<String>Actionable hint for fixing the error
Implementations§
Source§impl CoercionError
impl CoercionError
Sourcepub fn new(
message: &str,
source_error: impl Error,
received_value: Option<Value>,
) -> Self
pub fn new( message: &str, source_error: impl Error, received_value: Option<Value>, ) -> Self
Create a new coercion error.
Sourcepub fn with_parameter_path(self, path: String) -> Self
pub fn with_parameter_path(self, path: String) -> Self
Set the parameter path for this error.
Sourcepub fn with_expected_type(self, type_desc: &str) -> Self
pub fn with_expected_type(self, type_desc: &str) -> Self
Set the expected type description for this error.
Sourcepub fn to_mcp_error(&self) -> ErrorData
pub fn to_mcp_error(&self) -> ErrorData
Convert this error to an MCP error response.
Creates a structured JSON error that agents can parse and understand. Includes automatically generated recovery suggestions.
Trait Implementations§
Source§impl Clone for CoercionError
impl Clone for CoercionError
Source§fn clone(&self) -> CoercionError
fn clone(&self) -> CoercionError
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CoercionError
impl Debug for CoercionError
Source§impl Display for CoercionError
impl Display for CoercionError
Source§impl Error for CoercionError
impl Error for CoercionError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
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
fn description(&self) -> &str
👎Deprecated since 1.42.0:
use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for CoercionError
impl RefUnwindSafe for CoercionError
impl Send for CoercionError
impl Sync for CoercionError
impl Unpin for CoercionError
impl UnsafeUnpin for CoercionError
impl UnwindSafe for CoercionError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::RequestSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more