pub struct ZynkError {
pub code: &'static str,
pub message: String,
pub details: Option<Value>,
}Expand description
Runtime error type that can be converted into a JSON error envelope.
Fields§
§code: &'static strMachine-readable Zynk error code.
message: StringHuman-readable error message.
details: Option<Value>Optional structured error details.
Implementations§
Source§impl ZynkError
impl ZynkError
Sourcepub fn new(code: &'static str, message: impl Into<String>) -> Self
pub fn new(code: &'static str, message: impl Into<String>) -> Self
Create a runtime error without structured details.
Sourcepub fn with_details(
code: &'static str,
message: impl Into<String>,
details: Value,
) -> Self
pub fn with_details( code: &'static str, message: impl Into<String>, details: Value, ) -> Self
Create a runtime error with structured details.
Sourcepub fn into_envelope(self) -> JsonErrorEnvelope
pub fn into_envelope(self) -> JsonErrorEnvelope
Convert this runtime error into the JSON error envelope payload.
Trait Implementations§
Source§impl Error for ZynkError
impl Error for ZynkError
1.30.0 · 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()
impl StructuralPartialEq for ZynkError
Auto Trait Implementations§
impl Freeze for ZynkError
impl RefUnwindSafe for ZynkError
impl Send for ZynkError
impl Sync for ZynkError
impl Unpin for ZynkError
impl UnsafeUnpin for ZynkError
impl UnwindSafe for ZynkError
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