Skip to main content

ErrorCode

Trait ErrorCode 

Source
pub trait ErrorCode {
    // Required method
    fn code(&self) -> Message;
}
Expand description

Machine-readable code for errors that cross process or API boundaries.

Required Methods§

Source

fn code(&self) -> Message

Returns a stable code for control flow and public API responses.

Use message! to keep the code literal out of the binary, or Message::from_static for a plain literal. Comparison against &str works directly via Message’s PartialEq<&str>:

use redacted_error::{ErrorCode, Message};
if err.code() == "x.y" { /* ... */ }

Implementors§