From 25258409c09d408c1ccd332ffcdb6ed0e183f54d Mon Sep 17 00:00:00 2001 From: Daniel Mueller Date: Sun, 6 Jan 2019 16:58:32 -0800 Subject: Properly report io::Error objects We have a Result::unwrap in the error path of handling io::Error objects. I have actually seen that fail, masking the original error. We should not unwrap there and in fact we don't have to, as io::Error implements fmt::Display just fine. This may have changed in the past, as the construct we had is much more convoluted than necessary and would only have been written if a direct formatting was not possible. --- nitrocli/src/error.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nitrocli/src/error.rs b/nitrocli/src/error.rs index d86a635..738e689 100644 --- a/nitrocli/src/error.rs +++ b/nitrocli/src/error.rs @@ -1,7 +1,7 @@ // error.rs // ************************************************************************* -// * Copyright (C) 2017-2018 Daniel Mueller (deso@posteo.net) * +// * Copyright (C) 2017-2019 Daniel Mueller (deso@posteo.net) * // * * // * This program is free software: you can redistribute it and/or modify * // * it under the terms of the GNU General Public License as published by * @@ -46,7 +46,7 @@ impl fmt::Display for Error { match *self { Error::ArgparseError(_) => write!(f, "Could not parse arguments"), Error::Utf8Error(_) => write!(f, "Encountered UTF-8 conversion error"), - Error::IoError(ref e) => write!(f, "IO error: {}", e.get_ref().unwrap()), + Error::IoError(ref e) => write!(f, "IO error: {}", e), Error::Error(ref e) => write!(f, "{}", e), } } -- cgit v1.2.3