From: Josh Durgin Date: Mon, 21 Oct 2013 15:51:54 +0000 (-0700) Subject: buffer: add an exception with an error code X-Git-Tag: v0.74~65^2~6 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=eb94b8fd52c245bbcf305a0c91462ed0a291bd06;p=ceph.git buffer: add an exception with an error code This allows e.g. raw buffer constructors to provide more specific information about what failed, as well as a useful error string automatically. Signed-off-by: Josh Durgin --- diff --git a/src/common/buffer.cc b/src/common/buffer.cc index 2fdb2cab1915..7ac54390943a 100644 --- a/src/common/buffer.cc +++ b/src/common/buffer.cc @@ -69,6 +69,8 @@ static uint32_t simple_spinlock_t buffer_debug_lock = SIMPLE_SPINLOCK_INITIALIZE return buffer_cached_crc_adjusted.read(); } + buffer::error_code::error_code(int error) : + buffer::malformed_input(cpp_strerror(error).c_str()), code(error) {} class buffer::raw { public: diff --git a/src/include/buffer.h b/src/include/buffer.h index 0b497a7cf38d..3987f021601c 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -101,6 +101,10 @@ public: private: char buf[256]; }; + struct error_code : public malformed_input { + explicit error_code(int error); + int code; + }; /// total bytes allocated