use derive_more::From;
use orion_error::ErrorCode;
use orion_error::StructError;
use orion_error::UvsFrom;
use orion_error::UvsReason;
use serde::Serialize;
use thiserror::Error;
#[derive(Error, Debug, Clone, PartialEq, Serialize, From)]
pub enum OMLCodeReason {
#[error("{0}")]
Syntax(String),
#[from(skip)]
#[error("{0}")]
NotFound(String),
#[error("{0}")]
Uvs(UvsReason),
}
impl ErrorCode for OMLCodeReason {
fn error_code(&self) -> i32 {
crate::codes::SysErrorCode::sys_code(self) as i32
}
}
pub type OMLCodeError = StructError<OMLCodeReason>;
pub type OMLCodeResult<T> = Result<T, OMLCodeError>;
#[derive(Error, Debug, PartialEq)]
pub enum DataErrKind {
#[error("format error : {0}\n{1:?} ")]
FormatError(String, Option<String>),
#[error("not complete")]
NotComplete,
#[error("no parse data: {0}")]
UnParse(String),
#[error("less data")]
LessData,
#[error("empty data")]
EmptyData,
#[error("struct less : {0}")]
LessStc(String),
#[error("define less : {0}")]
LessDef(String),
}
impl From<DataErrKind> for OMLCodeReason {
fn from(_: DataErrKind) -> Self {
OMLCodeReason::from_data()
}
}
pub type OmlCodeResult<T> = Result<T, OMLCodeError>;
impl From<OMLCodeReason> for UvsReason {
fn from(_: OMLCodeReason) -> Self {
UvsReason::from_res()
}
}