pub struct ErrorKind(pub &'static str, pub &'static str, pub u16, pub &'static str);
Expand description
Represents a categorized error kind with associated metadata.
The ErrorKind
struct defines a specific type of error, providing
a unique identifier, category, numeric code, and a message ID.
This allows for structured and meaningful error classification.
§Example
let kind = cdumay_error::ErrorKind("NotFound", "MSG001", 404, "Not Found");
Tuple Fields§
§0: &'static str
A unique error identifier (name).
1: &'static str
A message ID associated with the error.
2: u16
A numeric error code.
3: &'static str
A human-readable description of the error.
Implementations§
Source§impl ErrorKind
impl ErrorKind
Sourcepub fn name(&self) -> &'static str
pub fn name(&self) -> &'static str
Returns the name of the error.
§Example
let error = cdumay_error::ErrorKind("NotFound", "MSG001", 404, "Not Found");
assert_eq!(error.name(), "NotFound");
Sourcepub fn message_id(&self) -> &'static str
pub fn message_id(&self) -> &'static str
Returns the message ID of the error.
§Example
let error = cdumay_error::ErrorKind("NotFound", "MSG001", 404, "Not Found");
assert_eq!(error.message_id(), "MSG001");
Sourcepub fn code(&self) -> u16
pub fn code(&self) -> u16
Returns the numerical error code.
§Example
let error = cdumay_error::ErrorKind("NotFound", "MSG001", 404, "Not Found");
assert_eq!(error.code(), 404);
Sourcepub fn description(&self) -> &'static str
pub fn description(&self) -> &'static str
Returns the description of the error.
§Example
let error = cdumay_error::ErrorKind("NotFound", "MSG001", 404, "Not Found");
assert_eq!(error.description(), "Not Found");
Sourcepub fn side(&self) -> &'static str
pub fn side(&self) -> &'static str
Determines whether the error originates from the client or the server.
- Errors with codes in the range 0 to 499 are classified as Client errors.
- Errors with codes 500 or higher are classified as Server errors.
§Example
let client_error = cdumay_error::ErrorKind("NotFound", "MSG001", 404, "Not Found");
assert_eq!(client_error.side(), "Client");
let server_error = cdumay_error::ErrorKind("InternalServerError", "MSG002", 500, "Internal Server Error");
assert_eq!(server_error.side(), "Server");
Trait Implementations§
impl StructuralPartialEq for ErrorKind
Auto Trait Implementations§
impl Freeze for ErrorKind
impl RefUnwindSafe for ErrorKind
impl Send for ErrorKind
impl Sync for ErrorKind
impl Unpin for ErrorKind
impl UnwindSafe for ErrorKind
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