ErrorMetadata

Trait ErrorMetadata 

Source
pub trait ErrorMetadata {
    // Required method
    fn code(&self) -> &'static str;

    // Provided methods
    fn description(&self) -> Option<&'static str> { ... }
    fn hints(&self) -> &'static [&'static str] { ... }
    fn role(&self) -> Role { ... }
    fn docs_url(&self) -> Option<&'static str> { ... }
    fn examples(&self) -> &'static [&'static str] { ... }
    fn related_codes(&self) -> &'static [&'static str] { ... }
    fn since_version(&self) -> Option<&'static str> { ... }
}
Expand description

Full error metadata for advanced documentation generation

Implement this trait on specific error types to export complete error definitions to JSON/docs with all metadata.

§Examples

use waddling_errors::{ErrorMetadata, Role};

struct ParserSyntax001;

impl ErrorMetadata for ParserSyntax001 {
    fn code(&self) -> &'static str {
        "E.PARSER.SYNTAX.001"
    }

    fn description(&self) -> Option<&'static str> {
        Some("Expected semicolon at end of statement")
    }

    fn hints(&self) -> &'static [&'static str] {
        &["Add a semicolon after the statement"]
    }

    fn role(&self) -> Role {
        Role::Public
    }
}

Required Methods§

Source

fn code(&self) -> &'static str

Get the full error code string (e.g., “E.PARSER.SYNTAX.001”)

Provided Methods§

Source

fn description(&self) -> Option<&'static str>

Human-readable description

Source

fn hints(&self) -> &'static [&'static str]

Helpful hints for fixing the error

Source

fn role(&self) -> Role

Documentation visibility role

Source

fn docs_url(&self) -> Option<&'static str>

URL to detailed documentation (if available)

Source

fn examples(&self) -> &'static [&'static str]

Example usage/messages

Source

fn related_codes(&self) -> &'static [&'static str]

Related error codes

Source

fn since_version(&self) -> Option<&'static str>

Version when this error was introduced

Implementors§