use thiserror::Error;
#[derive(Error, Debug, Clone, PartialEq)]
pub enum DiceError {
#[error("Invalid dice: {0}")]
InvalidDice(String),
#[error("Invalid parameter: {0}")]
InvalidParameter(String),
#[error("Arithmetic error: {0}")]
ArithmeticError(String),
#[cfg(feature = "parser")]
#[error("Parse error: {0}")]
ParseError(String),
#[error("Unsupported operation: {0}")]
UnsupportedOperation(String),
#[error("Invalid expression: {0}")]
InvalidExpression(String),
}
pub type DiceResult<T> = Result<T, DiceError>;
#[cfg(feature = "tool-call")]
impl From<DiceError> for rig::tool::ToolError {
fn from(err: DiceError) -> Self {
rig::tool::ToolError::ToolCallError(err.into())
}
}