Skip to main content

Module error_helpers

Module error_helpers 

Source
Expand description

Shared error helpers to reduce repetitive .with_context() patterns

Constants§

PATCH_PARAMETER_HINT
Standard hint when the model sends a patch payload to the wrong tool.
READ_FILE_FIRST_HINT
Canonical guidance to read a file before attempting a precise edit or patch.
USE_PATCH_FOR_LARGE_EDITS
Canonical guidance for routing large edits away from edit_file.
USE_PATCH_OR_WRITE_FOR_LARGE_FILES
Canonical guidance for routing large-file edits away from edit_file.

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.