Skip to content

Add non-breaking error category API #464

@srxg

Description

@srxg

Answering the question: "was this failure a validation error or something else?" should be trivial for downstream consumers.

#[derive(Copy, Clone, Debug, Eq, PartialEq)]
pub enum ErrorCategory { Fundamental, Validation, ThirdParty }

impl ErrorKind {
    pub fn category(&self) -> ErrorCategory {  todo!() }
    pub fn is_validation(&self) -> bool { matches!(self.category(), ErrorCategory::Validation) }
}

impl Error {
    pub fn category(&self) -> ErrorCategory { self.kind().category() }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions