diff options
author | Justus Winter <justus@sequoia-pgp.org> | 2020-03-27 10:31:52 +0100 |
---|---|---|
committer | Justus Winter <justus@sequoia-pgp.org> | 2020-03-27 10:44:39 +0100 |
commit | a41e4725c1d9096575986bad5e4ac81cb61e9a17 (patch) | |
tree | 7e04163573c322aea440e0139744cc1257c4aa88 /openpgp/src/lib.rs | |
parent | 8aeec7582ae89a1fcbc968880222afb020e80daf (diff) |
openpgp: Format timestamps in error messages.
- Fixes #459.
Diffstat (limited to 'openpgp/src/lib.rs')
-rw-r--r-- | openpgp/src/lib.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/openpgp/src/lib.rs b/openpgp/src/lib.rs index ca5de2cd..5ac45b36 100644 --- a/openpgp/src/lib.rs +++ b/openpgp/src/lib.rs @@ -285,15 +285,15 @@ pub enum Error { IndexOutOfRange, /// Expired. - #[error("Expired on {0:?}")] + #[error("Expired on {}", crate::fmt::time(.0))] Expired(std::time::SystemTime), /// Not yet live. - #[error("Not live until {0:?}")] + #[error("Not live until {}", crate::fmt::time(.0))] NotYetLive(std::time::SystemTime), /// No binding signature. - #[error("No binding signature at time {0:?}")] + #[error("No binding signature at time {}", crate::fmt::time(.0))] NoBindingSignature(std::time::SystemTime), /// Invalid key. @@ -304,7 +304,9 @@ pub enum Error { /// /// The optional time is the time at which the operation was /// determined to no longer be secure. - #[error("Not secure as of: {1:?}: {0}")] + #[error("Not secure{}: {0}", + .1.as_ref().map(|t| format!(" as of {}", crate::fmt::time(t))) + .unwrap_or("".into()))] PolicyViolation(String, Option<std::time::SystemTime>), /// This marks this enum as non-exhaustive. Do not use this |