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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
use std::io;
use tokio_util::codec::LinesCodecError;
/// The main crate-wide error type.
#[derive(Debug, Error)]
pub enum IrcError {
/// An internal I/O error.
#[error("an io error occurred")]
Io(#[from] io::Error),
// /// An internal TLS error.
// #[error("a TLS error occurred")]
// Tls(#[source] TlsError),
// /// An internal synchronous channel closed.
// #[error("a sync channel closed")]
// SyncChannelClosed(#[source] RecvError),
// /// An internal asynchronous channel closed.
// #[error("an async channel closed")]
// AsyncChannelClosed(#[source] SendError<Message>),
// /// An internal oneshot channel closed.
// #[error("a oneshot channel closed")]
// OneShotCanceled(#[source] Canceled),
// /// An internal timer error.
// #[error("timer failed")]
// Timer(#[source] TimerError),
// /// Error for invalid configurations.
// #[error("invalid config: {}", path)]
// InvalidConfig {
// /// The path to the configuration, or "<none>" if none specified.
// path: String,
// /// The detailed configuration error.
// #[source]
// cause: ConfigError,
// },
/// Error for invalid messages.
#[error("invalid message: {string}")]
InvalidMessage {
/// The string that failed to parse.
string: String,
/// The detailed message parsing error.
#[source]
cause: MessageParseError,
},
// /// Mutex for a logged transport was poisoned making the log inaccessible.
// #[error("mutex for a logged transport was poisoned")]
// PoisonedLog,
// /// Ping timed out due to no response.
// #[error("connection reset: no ping response")]
// PingTimeout,
// /// Failed to lookup an unknown codec.
// #[error("unknown codec: {}", codec)]
// UnknownCodec {
// /// The attempted codec.
// codec: String,
// },
// /// Failed to encode or decode something with the given codec.
// #[error("codec {} failed: {}", codec, data)]
// CodecFailed {
// /// The canonical codec name.
// codec: &'static str,
// /// The data that failed to encode or decode.
// data: String,
// },
/// Failed to encode or decode a line
#[error("line codec failed: {0}")]
Codec(#[from] LinesCodecError),
// /// All specified nicknames were in use or unusable.
// #[error("none of the specified nicknames were usable")]
// NoUsableNick,
// /// This allows you to produce any `failure::Error` within closures used by
// /// the irc crate. No errors of this kind will ever be produced by the crate
// /// itself.
// #[error("{}", inner)]
// Custom {
// /// The actual error that occurred.
// inner: failure::Error
// },
}
/// Errors that occur while parsing mode strings.
#[derive(Debug, Error)]
pub enum ModeParseError {
/// Invalid modifier used in a mode string (only + and - are valid).
#[error("invalid mode modifier: {modifier}")]
InvalidModeModifier {
/// The invalid mode modifier.
modifier: char,
},
/// Missing modifier used in a mode string.
#[error("missing mode modifier")]
MissingModeModifier,
}
/// Errors that occur when parsing messages.
#[derive(Debug, Error)]
pub enum MessageParseError {
/// The message was empty.
#[error("empty message")]
EmptyMessage,
/// The command was invalid (i.e. missing).
#[error("invalid command")]
InvalidCommand,
/// The mode string was malformed.
#[error("invalid mode string: {string}")]
InvalidModeString {
/// The invalid mode string.
string: String,
/// The detailed mode parsing error.
#[source]
cause: ModeParseError,
},
/// The subcommand used was invalid.
#[error("invalid {cmd} subcommand: {sub}")]
InvalidSubcommand {
/// The command whose invalid subcommand was referenced.
cmd: &'static str,
/// The invalid subcommand.
sub: String,
},
}