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>,
) -> CoercionError
pub fn new( message: &str, source_error: impl Error, received_value: Option<Value>, ) -> CoercionError
Create a new coercion error.
Sourcepub fn with_parameter_path(self, path: String) -> CoercionError
pub fn with_parameter_path(self, path: String) -> CoercionError
Set the parameter path for this error.
Sourcepub fn with_expected_type(self, type_desc: &str) -> CoercionError
pub fn with_expected_type(self, type_desc: &str) -> CoercionError
Set the expected type description for this error.
Sourcepub fn with_hint(self, hint: &str) -> CoercionError
pub fn with_hint(self, hint: &str) -> CoercionError
Set a hint for fixing 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
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
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)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
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
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>
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>
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>
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>
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>
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>
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString. Read more