compose_error_codes/
lib.rs

1use std::fmt::Debug;
2
3include!(concat!(env!("OUT_DIR"), "/error_codes.rs"));
4
5#[derive(Clone, Copy, PartialEq, Eq, Hash)]
6pub struct ErrorCode {
7    /// The error code (e.g. E0001)
8    pub code: &'static str,
9    /// The error name (e.g. `InvalidCharacter`)
10    pub name: &'static str,
11    /// The error description
12    /// 
13    /// A markdown string that explains the error and how it can be avoided.
14    pub description: &'static str,
15}
16
17impl Debug for ErrorCode {
18    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
19        write!(f, "{}({})", self.code, self.name)
20    }   
21}