Skip to main content

Module error

Module error 

Source
Expand description

Error handling utilities for RustyClaw.

§Error handling patterns

RustyClaw uses two error handling strategies:

  1. 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.

  2. Application logic (anyhow::Result): Internal application code uses anyhow for 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.