pub struct CuError { /* private fields */ }Expand description
Common copper Error type.
This error type stores an optional cause as a boxed dynamic error, allowing for proper error chaining while maintaining Clone and Serialize/Deserialize support through custom implementations.
Implementations§
Source§impl CuError
impl CuError
Sourcepub fn new(message_index: usize) -> CuError
pub fn new(message_index: usize) -> CuError
Creates a new CuError from an interned string index. Used by the cu_error! macro.
The index is stored as a placeholder string [interned:{index}].
Actual string resolution happens at logging time via the unified logger.
Sourcepub fn new_with_cause<E>(message: &str, cause: E) -> CuError
pub fn new_with_cause<E>(message: &str, cause: E) -> CuError
Creates a new CuError with a message and an underlying cause.
§Example
use cu29_traits::CuError;
let io_err = std::io::Error::other("io error");
let err = CuError::new_with_cause("Failed to read file", io_err);Sourcepub fn add_cause(self, context: &str) -> CuError
pub fn add_cause(self, context: &str) -> CuError
Adds or replaces the cause with a context string.
This is useful for adding context to errors during propagation.
§Example
use cu29_traits::CuError;
let err = CuError::from("base error").add_cause("additional context");Sourcepub fn with_cause<E>(self, cause: E) -> CuError
pub fn with_cause<E>(self, cause: E) -> CuError
Adds a cause error to this CuError (builder pattern).
§Example
use cu29_traits::CuError;
let io_err = std::io::Error::other("io error");
let err = CuError::from("Operation failed").with_cause(io_err);Trait Implementations§
Source§impl<'de> Deserialize<'de> for CuError
impl<'de> Deserialize<'de> for CuError
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Error for CuError
Available on crate feature std only.
impl Error for CuError
Available on crate feature
std only.Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
Auto Trait Implementations§
impl Freeze for CuError
impl !RefUnwindSafe for CuError
impl Send for CuError
impl Sync for CuError
impl Unpin for CuError
impl !UnwindSafe for CuError
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Serialize for T
impl<T> Serialize for T
fn erased_serialize(&self, serializer: &mut dyn Serializer) -> Result<(), Error>
fn do_erased_serialize( &self, serializer: &mut dyn Serializer, ) -> Result<(), ErrorImpl>
Source§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
Source§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
Fallible version of
ToCompactString::to_compact_string() Read moreSource§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a
CompactString. Read more