1use azathoth_core::errors::{AzError, ErrorClass};
2
3#[repr(u8)]
4#[derive(Debug, Clone, Copy, PartialEq, Eq)]
5pub enum AzUtilErrorCode {
6 FormatError = 0x01,
7 ParseError = 0x02,
8 NotFound = 0x03,
9 HashError = 0x04,
10 CodecError = 0x05,
11 UnexpectedEOF
12}
13
14impl core::fmt::Display for AzUtilErrorCode {
15 fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
16 match self {
17 Self::FormatError => write!(f,"format error"),
18 Self::NotFound => write!(f,"not found"),
19 Self::ParseError => write!(f,"parse error"),
20 Self::HashError => write!(f, "hash error"),
21 Self::CodecError => write!(f, "codec error"),
22 Self::UnexpectedEOF => write!(f, "unexpected EOF")
23 }
24 }
25}
26
27impl AzError for AzUtilErrorCode {
28 const CLASS: ErrorClass = ErrorClass::Other;
29 fn code(&self) -> u16 {
30 *self as u16
31 }
32 fn is_retryable(&self) -> bool {
33 false
34 }
35 fn os_code(&self) -> Option<u32> {
36 None
37 }
38}
39
40pub type AzUtilResult<T> = Result<T, AzUtilErrorCode>;