incise_core/error.rs
1//! A failure whose message is handed straight back to a model.
2//!
3//! Not an error type in the usual Rust sense: the string *is* the product
4//! (REQUIREMENTS.md §5.3). Arm B measured recovery rates against these exact
5//! sentences — 75% of `op_error` trials recover in one extra turn — so the
6//! wording is behaviour, not diagnostics, and `bench/incise_ops.py` is the
7//! oracle for it byte-for-byte.
8
9use std::fmt;
10
11#[derive(Debug, Clone, PartialEq, Eq)]
12pub struct OpError(pub String);
13
14impl OpError {
15 pub fn new(msg: impl Into<String>) -> Self {
16 OpError(msg.into())
17 }
18
19 pub fn message(&self) -> &str {
20 &self.0
21 }
22}
23
24impl fmt::Display for OpError {
25 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
26 f.write_str(&self.0)
27 }
28}
29
30impl std::error::Error for OpError {}
31
32pub type Result<T> = std::result::Result<T, OpError>;