1use std;
2use std::fmt::{self, Display};
3use std::num::ParseIntError;
4
5use serde::{de, ser};
6
7pub type Result<T> = std::result::Result<T, Error>;
8
9#[derive(Clone, Debug, PartialEq)]
14pub enum Error {
15 Message(String),
21
22 UnknownFieldName(String),
23
24 UnknownFieldType(String),
25
26 InvalidAddress,
27
28 InvalidAmount(ParseIntError, String),
29 InvalidIssuedCurrencyAmount(String),
30
31 InvalidTransactionType(String),
32}
33
34impl ser::Error for Error {
35 fn custom<T: Display>(msg: T) -> Self {
36 Error::Message(msg.to_string())
37 }
38}
39
40impl de::Error for Error {
41 fn custom<T: Display>(msg: T) -> Self {
42 Error::Message(msg.to_string())
43 }
44}
45
46impl Display for Error {
47 fn fmt(&self, formatter: &mut fmt::Formatter) -> fmt::Result {
48 match self {
49 _ => write!(formatter, "{:?}", self),
50 }
51 }
52}
53
54impl std::error::Error for Error {}