Struct CuError
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§
§impl CuError
impl CuError
pub 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.
pub 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);pub 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");pub 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§
§impl<'de> Deserialize<'de> for CuError
impl<'de> Deserialize<'de> for CuError
§fn deserialize<D>(
deserializer: D,
) -> Result<CuError, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<CuError, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
§impl Error for CuError
Available on crate feature std only.
impl Error for CuError
Available on crate feature
std only.§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()
Source§impl From<ConfigError> for CuError
impl From<ConfigError> for CuError
Source§fn from(err: ConfigError) -> CuError
fn from(err: ConfigError) -> CuError
Converts to this type from the input type.
§impl Serialize for CuError
impl Serialize for CuError
§fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
fn serialize<S>(
&self,
serializer: S,
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,
Serialize this value into the given Serde serializer. Read more
Auto Trait Implementations§
impl Freeze for CuError
impl !RefUnwindSafe for CuError
impl Send for CuError
impl Sync for CuError
impl Unpin for CuError
impl UnsafeUnpin 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,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> Pointable for T
impl<T> Pointable for T
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>
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§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 more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
Converts the given value to a [
CompactString]. Read more§impl<T> TypeData for T
impl<T> TypeData for T
§fn clone_type_data(&self) -> Box<dyn TypeData>
fn clone_type_data(&self) -> Box<dyn TypeData>
Creates a type-erased clone of this value.