use serde::Serialize;
use thiserror::Error;
#[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<String> for DataErrKind {
fn from(value: String) -> Self {
DataErrKind::FormatError(value, None)
}
}
use derive_more::From;
use orion_error::ErrorCode;
use orion_error::StructError;
use orion_error::ToStructError;
use orion_error::UvsFrom;
use orion_error::UvsReason;
#[derive(Error, Debug, Clone, PartialEq, Serialize, From)]
pub enum WparseReason {
#[from(skip)]
#[error("plugin >{0}")]
Plugin(String),
#[error("not match")]
NotMatch,
#[error("line proc > {0}")]
LineProc(String),
#[error("{0}")]
Uvs(UvsReason),
}
impl ErrorCode for WparseReason {
fn error_code(&self) -> i32 {
500
}
}
pub type WparseError = StructError<WparseReason>;
impl From<DataErrKind> for WparseError {
fn from(value: DataErrKind) -> Self {
WparseReason::from_data()
.to_err()
.with_detail(format!("{}", value))
}
}
pub type WparseResult<T> = Result<T, WparseError>;
#[deprecated(note = "use `WparseReason` instead")]
pub type WplParseReason = WparseReason;
#[deprecated(note = "use `WparseError` instead")]
pub type WplParseError = WparseError;
#[deprecated(note = "use `WparseResult` instead")]
pub type WplParseResult<T> = WparseResult<T>;