| 1 | //! IRC protocol errors using `failure`. |
| 2 | |
| 3 | use thiserrorrust-analyzer cargo thiserror 1.0.69 crate/::Errorrust-analyzer cargo thiserror-impl 1.0.69 Error:; |
| 4 | |
| 5 | /// A `Result` type for IRC `ProtocolErrors`. |
| 6 | pub type Resultrust-analyzer cargo irc-proto 1.1.0 error/Result#<T, E = ProtocolErrorrust-analyzer cargo irc-proto 1.1.0 error/ProtocolError#> = ::stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/::Resultrust-analyzer cargo core https://github.com/rust-lang/rust/library/core result/Result#<T, E>; |
| 7 | |
| 8 | /// An IRC protocol error. |
| 9 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Errorrust-analyzer cargo thiserror-impl 1.0.69 Error:)] |
| 10 | pub enum ProtocolErrorrust-analyzer cargo irc-proto 1.1.0 error/ProtocolError# { |
| 11 | /// An internal I/O error. |
| 12 | #[errorrust-analyzer cargo thiserror-impl 1.0.69 error:("an io error occurred")] |
| 13 | Iorust-analyzer cargo irc-proto 1.1.0 error/ProtocolError#Io#(#[source] stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#), |
| 14 | |
| 15 | /// Error for invalid messages. |
| 16 | #[errorrust-analyzer cargo thiserror-impl 1.0.69 error:("invalid message: {}", string)] |
| 17 | InvalidMessagerust-analyzer cargo irc-proto 1.1.0 error/ProtocolError#InvalidMessage# { |
| 18 | /// The string that failed to parse. |
| 19 | stringrust-analyzer cargo irc-proto 1.1.0 error/ProtocolError#InvalidMessage#string.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 20 | /// The detailed message parsing error. |
| 21 | #[source] |
| 22 | causerust-analyzer cargo irc-proto 1.1.0 error/ProtocolError#InvalidMessage#cause.: MessageParseErrorrust-analyzer cargo irc-proto 1.1.0 error/MessageParseError#, |
| 23 | }, |
| 24 | } |
| 25 | |
| 26 | impl Fromrust-analyzer cargo core https://github.com/rust-lang/rust/library/core convert/From#<stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#> for ProtocolErrorrust-analyzer cargo irc-proto 1.1.0 error/ProtocolError# { |
| 27 | fn fromrust-analyzer cargo irc-proto 1.1.0 error/impl#[ProtocolError][`From<std::io::Error>`]from().(e: stdrust-analyzer cargo std https://github.com/rust-lang/rust/library/std crate/::iorust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/::Errorrust-analyzer cargo std https://github.com/rust-lang/rust/library/std io/error/Error#) -> ProtocolErrorrust-analyzer cargo irc-proto 1.1.0 error/ProtocolError# { |
| 28 | ProtocolErrorrust-analyzer cargo irc-proto 1.1.0 error/ProtocolError#::Iorust-analyzer cargo irc-proto 1.1.0 error/ProtocolError#Io#(e) |
| 29 | } |
| 30 | } |
| 31 | |
| 32 | /// Errors that occur when parsing messages. |
| 33 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Errorrust-analyzer cargo thiserror-impl 1.0.69 Error:)] |
| 34 | pub enum MessageParseErrorrust-analyzer cargo irc-proto 1.1.0 error/MessageParseError# { |
| 35 | /// The message was empty. |
| 36 | #[errorrust-analyzer cargo thiserror-impl 1.0.69 error:("empty message")] |
| 37 | EmptyMessagerust-analyzer cargo irc-proto 1.1.0 error/MessageParseError#EmptyMessage#, |
| 38 | |
| 39 | /// The command was invalid (i.e. missing). |
| 40 | #[errorrust-analyzer cargo thiserror-impl 1.0.69 error:("invalid command")] |
| 41 | InvalidCommandrust-analyzer cargo irc-proto 1.1.0 error/MessageParseError#InvalidCommand#, |
| 42 | |
| 43 | /// The mode string was malformed. |
| 44 | #[errorrust-analyzer cargo thiserror-impl 1.0.69 error:("invalid mode string: {}", string)] |
| 45 | InvalidModeStringrust-analyzer cargo irc-proto 1.1.0 error/MessageParseError#InvalidModeString# { |
| 46 | /// The invalid mode string. |
| 47 | stringrust-analyzer cargo irc-proto 1.1.0 error/MessageParseError#InvalidModeString#string.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 48 | /// The detailed mode parsing error. |
| 49 | #[source] |
| 50 | causerust-analyzer cargo irc-proto 1.1.0 error/MessageParseError#InvalidModeString#cause.: ModeParseErrorrust-analyzer cargo irc-proto 1.1.0 error/ModeParseError#, |
| 51 | }, |
| 52 | |
| 53 | /// The subcommand used was invalid. |
| 54 | #[errorrust-analyzer cargo thiserror-impl 1.0.69 error:("invalid {} subcommand: {}", cmd, sub)] |
| 55 | InvalidSubcommandrust-analyzer cargo irc-proto 1.1.0 error/MessageParseError#InvalidSubcommand# { |
| 56 | /// The command whose invalid subcommand was referenced. |
| 57 | cmdrust-analyzer cargo irc-proto 1.1.0 error/MessageParseError#InvalidSubcommand#cmd.: &'static str, |
| 58 | /// The invalid subcommand. |
| 59 | subrust-analyzer cargo irc-proto 1.1.0 error/MessageParseError#InvalidSubcommand#sub.: Stringrust-analyzer cargo alloc https://github.com/rust-lang/rust/library/alloc string/String#, |
| 60 | }, |
| 61 | } |
| 62 | |
| 63 | /// Errors that occur while parsing mode strings. |
| 64 | #[deriverust-analyzer cargo core https://github.com/rust-lang/rust/library/core macros/builtin/derive:(Debugrust-analyzer cargo core https://github.com/rust-lang/rust/library/core fmt/macros/Debug:, Errorrust-analyzer cargo thiserror-impl 1.0.69 Error:)] |
| 65 | pub enum ModeParseErrorrust-analyzer cargo irc-proto 1.1.0 error/ModeParseError# { |
| 66 | /// Invalid modifier used in a mode string (only + and - are valid). |
| 67 | #[errorrust-analyzer cargo thiserror-impl 1.0.69 error:("invalid mode modifier: {}", modifier)] |
| 68 | InvalidModeModifierrust-analyzer cargo irc-proto 1.1.0 error/ModeParseError#InvalidModeModifier# { |
| 69 | /// The invalid mode modifier. |
| 70 | modifierrust-analyzer cargo irc-proto 1.1.0 error/ModeParseError#InvalidModeModifier#modifier.: char, |
| 71 | }, |
| 72 | |
| 73 | /// Missing modifier used in a mode string. |
| 74 | #[errorrust-analyzer cargo thiserror-impl 1.0.69 error:("missing mode modifier")] |
| 75 | MissingModeModifierrust-analyzer cargo irc-proto 1.1.0 error/ModeParseError#MissingModeModifier#, |
| 76 | } |