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