1use derive_more::From;
2use orion_error::ErrorCode;
3use orion_error::StructError;
4use orion_error::UvsFrom;
5use orion_error::UvsReason;
6use serde::Serialize;
7use thiserror::Error;
8
9#[derive(Error, Debug, Clone, PartialEq, Serialize, From)]
41pub enum OMLCodeReason {
42 #[error("{0}")]
43 Syntax(String),
44 #[from(skip)]
45 #[error("{0}")]
46 NotFound(String),
47 #[error("{0}")]
48 Uvs(UvsReason),
49}
50impl ErrorCode for OMLCodeReason {
51 fn error_code(&self) -> i32 {
52 crate::codes::SysErrorCode::sys_code(self) as i32
53 }
54}
55
56pub type OMLCodeError = StructError<OMLCodeReason>;
57
58pub type OMLCodeResult<T> = Result<T, OMLCodeError>;
59
60#[derive(Error, Debug, PartialEq)]
61pub enum DataErrKind {
62 #[error("format error : {0}\n{1:?} ")]
63 FormatError(String, Option<String>),
64 #[error("not complete")]
65 NotComplete,
66 #[error("no parse data: {0}")]
67 UnParse(String),
68
69 #[error("less data")]
70 LessData,
71 #[error("empty data")]
72 EmptyData,
73 #[error("struct less : {0}")]
74 LessStc(String),
75 #[error("define less : {0}")]
76 LessDef(String),
77}
78impl From<DataErrKind> for OMLCodeReason {
79 fn from(_: DataErrKind) -> Self {
80 OMLCodeReason::from_data()
81 }
82}
83pub type OmlCodeResult<T> = Result<T, OMLCodeError>;
84
85impl From<OMLCodeReason> for UvsReason {
88 fn from(_: OMLCodeReason) -> Self {
89 UvsReason::from_res()
90 }
91}