Skip to main content

wp_error/
parse_error.rs

1use derive_more::From;
2use orion_error::{OrionError, StructError, UnifiedReason};
3use serde::Serialize;
4use thiserror::Error;
5
6#[derive(Debug, Clone, PartialEq, Serialize, From, OrionError)]
7pub enum OMLCodeReason {
8    #[orion_error(identity = "biz.syntax")]
9    Syntax(String),
10    #[orion_error(identity = "biz.not_found")]
11    #[from(skip)]
12    NotFound(String),
13    #[orion_error(transparent)]
14    Uvs(UnifiedReason),
15}
16
17pub type OMLCodeError = StructError<OMLCodeReason>;
18
19pub type OMLCodeResult<T> = Result<T, OMLCodeError>;
20
21#[derive(Error, Debug, PartialEq)]
22pub enum DataErrKind {
23    #[error("format error : {0}\n{1:?} ")]
24    FormatError(String, Option<String>),
25    #[error("not complete")]
26    NotComplete,
27    #[error("no parse data: {0}")]
28    UnParse(String),
29
30    #[error("less data")]
31    LessData,
32    #[error("empty data")]
33    EmptyData,
34    #[error("struct less : {0}")]
35    LessStc(String),
36    #[error("define less : {0}")]
37    LessDef(String),
38}
39impl From<DataErrKind> for OMLCodeReason {
40    fn from(_: DataErrKind) -> Self {
41        OMLCodeReason::data_error()
42    }
43}
44pub type OmlCodeResult<T> = Result<T, OMLCodeError>;
45
46impl From<OMLCodeReason> for UnifiedReason {
47    fn from(_: OMLCodeReason) -> Self {
48        UnifiedReason::resource_error()
49    }
50}