]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
buffer: add an exception with an error code
authorJosh Durgin <josh.durgin@inktank.com>
Mon, 21 Oct 2013 15:51:54 +0000 (08:51 -0700)
committerJosh Durgin <josh.durgin@inktank.com>
Sat, 23 Nov 2013 00:14:03 +0000 (16:14 -0800)
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 <josh.durgin@inktank.com>
src/common/buffer.cc
src/include/buffer.h

index 2fdb2cab1915294c638cf064870f0822095949c2..7ac54390943a559660a68680e6765bc01d7bb81a 100644 (file)
@@ -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:
index 0b497a7cf38d6344d9b1ce290ce4aed4abb21db6..3987f021601cdfbd743ae3d0d7c2a0e4814175c0 100644 (file)
@@ -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