1use derive_more::From;
2use orion_error::{OrionError, StructError, UvsFrom, UvsReason};
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(UvsReason),
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::from_data()
42 }
43}
44pub type OmlCodeResult<T> = Result<T, OMLCodeError>;
45
46impl From<OMLCodeReason> for UvsReason {
47 fn from(_: OMLCodeReason) -> Self {
48 UvsReason::from_res()
49 }
50}