Expand description
Error handling utilities for RustyClaw.
§Error handling patterns
RustyClaw uses two error handling strategies:
-
Tools (
Result<String, String>): Tools return simple string errors because these are sent back to the AI model. The error message is displayed to the model which can then try to recover or report the issue to the user. -
Application logic (
anyhow::Result): Internal application code usesanyhowfor its rich error context and easy propagation.
§Converting between error types
Use the anyhow_to_tool_err and tool_err_to_anyhow functions to convert
between the two error types when needed.
Functions§
- anyhow_
to_ tool_ err - Convert an anyhow error to a tool error (string message).
- anyhow_
to_ tool_ result - Convert an anyhow result to a tool result.
- tool_
err_ to_ anyhow - Convert a tool error to an anyhow error.
- tool_
to_ anyhow_ result - Convert a tool result to an anyhow result.