1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
use thiserror::Error;
#[derive(Debug, Error)]
pub enum ProtocolError {
#[error("message has wrong type")]
WrongMsgType,
#[error("message has unkown type")]
UnknownMsgType,
#[error("bool value is neither 0 nor 1")]
BoolOutOfRange,
#[error("Sync Message does not contain any more parameters")]
MissingSyncMessageParams,
#[error("QVariant is not known")]
UnknownVariant,
#[error("UserType is not known: {0}")]
UnknownUserType(String),
#[error("wrong variant has been given")]
WrongVariant,
#[error("missing required field: {0}")]
MissingField(String),
#[error("io error: {0}")]
IOError(#[from] std::io::Error),
#[error("could not convert from int: {0}")]
TryFromIntError(#[from] std::num::TryFromIntError),
#[error("utf8 error: {0}")]
Utf8Error(#[from] std::string::FromUtf8Error),
#[error("utf16 error: {0}")]
Utf16Error(#[from] std::string::FromUtf16Error),
#[error("errored to parse char as utf16")]
CharError,
#[error("failed to deal with time: {0}")]
TimeError(#[from] time::error::ComponentRange),
#[error("failed to parse int: {0}")]
ParseIntError(#[from] std::num::ParseIntError),
#[error("error in sync proxy: {0}")]
SyncProxyError(#[from] SyncProxyError),
#[error("got unkown HighlightNickType: {0}")]
UnknownHighlightNickType(i32),
#[error("got unkown IgnoreType: {0}")]
UnknownIgnoreType(i32),
#[error("got unkown StrictnessType: {0}")]
UnknownStrictnessType(i32),
#[error("got unkown ScopeType: {0}")]
UnknownScopeType(i32),
}
#[derive(Debug, Error)]
pub enum SyncProxyError {
#[error("SYNC_PROXY was already initialized")]
AlreadyInitialized,
#[error("SYNC_PROXY was not yet initialized")]
NotInitialized,
}
pub type Result<T> = std::result::Result<T, ProtocolError>;
// impl std::error::Error for ErrorKind {}
//
// impl std::convert::From<std::io::Error> for ErrorKind {
// fn from(error: std::io::Error) -> Self {
// ErrorKind::IOError(error)
// }
// }
//
// impl std::convert::From<std::num::TryFromIntError> for ErrorKind {
// fn from(error: std::num::TryFromIntError) -> Self {
// ErrorKind::TryFromIntError(error)
// }
// }
//
// impl std::convert::From<std::string::FromUtf8Error> for ErrorKind {
// fn from(error: std::string::FromUtf8Error) -> Self {
// ErrorKind::Utf8Error(error)
// }
// }
|