Always include something in ErrorStack's Display

The error stack can be empty after a some kinds of errors (AEAD
validation failure in Crypter is one example), and we don't want to
display as an empty string in that case.
This commit is contained in:
Steven Fackler 2018-02-27 15:55:03 -08:00
parent 42ec251b55
commit 85d8db21d2
1 changed files with 4 additions and 0 deletions

View File

@ -59,6 +59,10 @@ impl ErrorStack {
impl fmt::Display for ErrorStack { impl fmt::Display for ErrorStack {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
if self.0.is_empty() {
return fmt.write_str("OpenSSL error");
}
let mut first = true; let mut first = true;
for err in &self.0 { for err in &self.0 {
if !first { if !first {