|
5 | 5 |
|
6 | 6 | use crate::curve::KeyType;
|
7 | 7 |
|
| 8 | +use displaydoc::Display; |
8 | 9 | use thiserror::Error;
|
9 | 10 |
|
10 | 11 | use std::fmt;
|
@@ -37,89 +38,89 @@ impl std::error::Error for CallbackErrorWrapper {
|
37 | 38 | }
|
38 | 39 | }
|
39 | 40 |
|
40 |
| -#[derive(Debug, Error)] |
| 41 | +#[derive(Debug, Display, Error)] |
41 | 42 | pub enum SignalProtocolError {
|
42 |
| - #[error("invalid argument: {}", .0)] |
| 43 | + /// invalid argument: {0} |
43 | 44 | InvalidArgument(String),
|
44 |
| - #[error("invalid state for call to {} to succeed: {}", .0, .1)] |
| 45 | + /// invalid state for call to {0} to succeed: {1} |
45 | 46 | InvalidState(&'static str, String),
|
46 | 47 |
|
47 |
| - #[error("failed to decode protobuf: {}", .0)] |
| 48 | + /// failed to decode protobuf: {0} |
48 | 49 | ProtobufDecodingError(#[from] prost::DecodeError),
|
49 |
| - #[error("failed to encode protobuf: {}", .0)] |
| 50 | + /// failed to encode protobuf: {0} |
50 | 51 | ProtobufEncodingError(#[from] prost::EncodeError),
|
51 |
| - #[error("protobuf encoding was invalid")] |
| 52 | + /// protobuf encoding was invalid |
52 | 53 | InvalidProtobufEncoding,
|
53 | 54 |
|
54 |
| - #[error("ciphertext serialized bytes were too short <{}>", .0)] |
| 55 | + /// ciphertext serialized bytes were too short <{0}> |
55 | 56 | CiphertextMessageTooShort(usize),
|
56 |
| - #[error("ciphertext version was too old <{}>", .0)] |
| 57 | + /// ciphertext version was too old <{0}> |
57 | 58 | LegacyCiphertextVersion(u8),
|
58 |
| - #[error("ciphertext version was unrecognized <{}>", .0)] |
| 59 | + /// ciphertext version was unrecognized <{0}> |
59 | 60 | UnrecognizedCiphertextVersion(u8),
|
60 |
| - #[error("unrecognized message version <{}>", .0)] |
| 61 | + /// unrecognized message version <{0}> |
61 | 62 | UnrecognizedMessageVersion(u32),
|
62 | 63 |
|
63 |
| - #[error("fingerprint identifiers do not match")] |
| 64 | + /// fingerprint identifiers do not match |
64 | 65 | FingerprintIdentifierMismatch,
|
65 |
| - #[error("fingerprint version number mismatch them {} us {}", .0, .1)] |
| 66 | + /// fingerprint version number mismatch them {0} us {1} |
66 | 67 | FingerprintVersionMismatch(u32, u32),
|
67 |
| - #[error("fingerprint parsing error")] |
| 68 | + /// fingerprint parsing error |
68 | 69 | FingerprintParsingError,
|
69 | 70 |
|
70 |
| - #[error("no key type identifier")] |
| 71 | + /// no key type identifier |
71 | 72 | NoKeyTypeIdentifier,
|
72 |
| - #[error("bad key type <{:#04x}>", .0)] |
| 73 | + /// bad key type <{0:#04x}> |
73 | 74 | BadKeyType(u8),
|
74 |
| - #[error("bad key length <{}> for key with type <{}>", .1, .0)] |
| 75 | + /// bad key length <{0}> for key with type <{1}> |
75 | 76 | BadKeyLength(KeyType, usize),
|
76 | 77 |
|
77 |
| - #[error("invalid signature detected")] |
| 78 | + /// invalid signature detected |
78 | 79 | SignatureValidationFailed,
|
79 | 80 |
|
80 |
| - #[error("untrusted identity for address {}", .0)] |
| 81 | + /// untrusted identity for address {0} |
81 | 82 | UntrustedIdentity(crate::ProtocolAddress),
|
82 | 83 |
|
83 |
| - #[error("invalid prekey identifier")] |
| 84 | + /// invalid prekey identifier |
84 | 85 | InvalidPreKeyId,
|
85 |
| - #[error("invalid signed prekey identifier")] |
| 86 | + /// invalid signed prekey identifier |
86 | 87 | InvalidSignedPreKeyId,
|
87 | 88 |
|
88 |
| - #[error("invalid root key length <{}>", .0)] |
| 89 | + /// invalid root key length <{0}> |
89 | 90 | InvalidRootKeyLength(usize),
|
90 |
| - #[error("invalid chain key length <{}>", .0)] |
| 91 | + /// invalid chain key length <{0}> |
91 | 92 | InvalidChainKeyLength(usize),
|
92 | 93 |
|
93 |
| - #[error("invalid MAC key length <{}>", .0)] |
| 94 | + /// invalid MAC key length <{0}> |
94 | 95 | InvalidMacKeyLength(usize),
|
95 |
| - #[error("invalid cipher key length <{}> or nonce length <{}>", .0, .1)] |
| 96 | + /// invalid cipher key length <{0}> or nonce length <{1}> |
96 | 97 | InvalidCipherCryptographicParameters(usize, usize),
|
97 |
| - #[error("invalid ciphertext message")] |
| 98 | + /// invalid ciphertext message |
98 | 99 | InvalidCiphertext,
|
99 | 100 |
|
100 |
| - #[error("no sender key state")] |
| 101 | + /// no sender key state |
101 | 102 | NoSenderKeyState,
|
102 | 103 |
|
103 |
| - #[error("session with '{}' not found", .0)] |
| 104 | + /// session with '{0}' not found |
104 | 105 | SessionNotFound(String),
|
105 |
| - #[error("invalid session structure")] |
| 106 | + /// invalid session structure |
106 | 107 | InvalidSessionStructure,
|
107 | 108 |
|
108 |
| - #[error("message with old counter {} / {}", .0, .1)] |
| 109 | + /// message with old counter {0} / {1} |
109 | 110 | DuplicatedMessage(u32, u32),
|
110 |
| - #[error("invalid message {}", .0)] |
| 111 | + /// invalid message {0} |
111 | 112 | InvalidMessage(&'static str),
|
112 |
| - #[error("internal error {}", .0)] |
| 113 | + /// internal error {0} |
113 | 114 | InternalError(&'static str),
|
114 |
| - #[error("error while invoking an ffi callback: {}", .0)] |
| 115 | + /// error while invoking an ffi callback: {0} |
115 | 116 | FfiBindingError(String),
|
116 |
| - #[error("error in method call '{}': {}", .0, .1)] |
| 117 | + /// error in method call '{0}': {1} |
117 | 118 | ApplicationCallbackError(&'static str, #[source] CallbackErrorWrapper),
|
118 | 119 |
|
119 |
| - #[error("invalid sealed sender message {}", .0)] |
| 120 | + /// invalid sealed sender message {0} |
120 | 121 | InvalidSealedSenderMessage(String),
|
121 |
| - #[error("unknown sealed sender message version {}", .0)] |
| 122 | + /// unknown sealed sender message version {0} |
122 | 123 | UnknownSealedSenderVersion(u8),
|
123 |
| - #[error("self send of a sealed sender message")] |
| 124 | + /// self send of a sealed sender message |
124 | 125 | SealedSenderSelfSend,
|
125 | 126 | }
|
0 commit comments