Skip to main content

Module error_helpers

Module error_helpers 

Source
Expand description

Shared error helpers to reduce repetitive .with_context() patterns

Functionsยง

deserialize_tool_args
Deserialize JSON tool arguments into a typed struct with a consistent error message.
optional_string_field
Extract an optional string field from JSON args
require_field
Extract a required value from an Option<T>, with a consistent error message referencing the field name and tool/operation name.
require_int_field
Extract a required integer field from JSON args
require_string_field
Extract a required string field from JSON args, with a consistent error message
with_file_context
Wrap a file operation result with standardized path context. Works with any Result<T, E> where E implements std::error::Error.
with_path_context
Like with_file_context but accepts a string path instead of &Path.