From 02d033667ae5aefad1aa7453692e0605cc591efc Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Thu, 9 Jun 2016 09:01:01 +0300 Subject: [PATCH] utils: Improve storage_io_exception error message Make storage_io_exception exception error message less cryptic by actually including the human-readable error message from std::system_error... Before: nodetool: Scylla API server HTTP POST to URL '/storage_service/snapshots' failed: Storage io error errno: 2 After: nodetool: Scylla API server HTTP POST to URL '/storage_service/snapshots' failed: Storage I/O error: 2: No such file or directory We can improve this further by including the name of the file that the I/O error happened on. Message-Id: <1465452061-15474-1-git-send-email-penberg@scylladb.com> --- utils/exceptions.hh | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/utils/exceptions.hh b/utils/exceptions.hh index 95c090e8e7..b071d04743 100644 --- a/utils/exceptions.hh +++ b/utils/exceptions.hh @@ -35,10 +35,9 @@ private: std::string _what; public: storage_io_error(std::system_error& e) noexcept - { - _code = e.code(); - _what = std::string("Storage io error errno: ") + std::to_string(_code.value()); - } + : _code{e.code()} + , _what{std::string("Storage I/O error: ") + std::to_string(e.code().value()) + ": " + e.what()} + { } virtual const char* what() const noexcept override { return _what.c_str();