Skip to content

Add non-breaking error category API #464

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() }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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