1use serde::Serialize;
2use thiserror::Error;
3
4#[derive(Error, Debug, PartialEq)]
5pub enum DataErrKind {
6 #[error("format error : {0}\n{1:?} ")]
7 FormatError(String, Option<String>),
8 #[error("not complete")]
9 NotComplete,
10 #[error("no parse data: {0}")]
11 UnParse(String),
12
13 #[error("less data")]
14 LessData,
15 #[error("empty data")]
16 EmptyData,
17 #[error("struct less : {0}")]
18 LessStc(String),
19 #[error("define less : {0}")]
20 LessDef(String),
21}
22
23impl From<String> for DataErrKind {
24 fn from(value: String) -> Self {
25 DataErrKind::FormatError(value, None)
26 }
27}
28
29use derive_more::From;
30use orion_error::conversion::ToStructError;
31use orion_error::{OrionError, StructError, UnifiedReason};
32
33#[derive(Debug, Clone, PartialEq, Serialize, From, OrionError)]
34pub enum WparseReason {
35 #[orion_error(identity = "biz.plugin")]
36 #[from(skip)]
37 Plugin(String),
38 #[orion_error(identity = "biz.not_match", message = "not match")]
39 NotMatch,
40 #[orion_error(identity = "biz.line_proc")]
41 LineProc(String),
42 #[orion_error(transparent)]
43 Uvs(UnifiedReason),
44}
45
46pub type WparseError = StructError<WparseReason>;
47
48impl From<DataErrKind> for WparseError {
49 fn from(value: DataErrKind) -> Self {
50 WparseReason::data_error()
51 .to_err()
52 .with_detail(format!("{}", value))
53 }
54}
55pub type WparseResult<T> = Result<T, WparseError>;
56
57#[deprecated(note = "use `WparseReason` instead")]
59pub type WplParseReason = WparseReason;
60
61#[deprecated(note = "use `WparseError` instead")]
62pub type WplParseError = WparseError;
63
64#[deprecated(note = "use `WparseResult` instead")]
65pub type WplParseResult<T> = WparseResult<T>;