susumu.yata
null+****@clear*****
Mon Jul 1 18:08:06 JST 2013
susumu.yata 2013-07-01 18:08:06 +0900 (Mon, 01 Jul 2013) New Revision: 057221e10fe953c6c93220f371042e0381c3d4aa https://github.com/groonga/grnxx/commit/057221e10fe953c6c93220f371042e0381c3d4aa Message: Remove File/MmapError and add SystemError. Modified files: lib/grnxx/exception.hpp Modified: lib/grnxx/exception.hpp (+23 -15) =================================================================== --- lib/grnxx/exception.hpp 2013-07-01 16:39:45 +0900 (4738cad) +++ lib/grnxx/exception.hpp 2013-07-01 18:08:06 +0900 (12e9814) @@ -22,6 +22,8 @@ #include <exception> +#include "grnxx/errno.hpp" + namespace grnxx { // The base exception class. @@ -35,37 +37,43 @@ class Exception : std::exception { } }; -// This exception is thrown when a file operation fails. -class FileError : public Exception { +// Thrown as an exception when a logical error occurs. +class LogicError : public Exception { public: - FileError() noexcept {} - virtual ~FileError() noexcept {} + LogicError() noexcept {} + virtual ~LogicError() noexcept {} virtual const char *what() const noexcept { - return "grnxx::FileError"; + return "grnxx::LogicError"; } }; -// This exception is thrown when memory mapping fails. -class MmapError : public Exception { +// Thrown as an exception when memory allocation fails. +class MemoryError : public Exception { public: - MmapError() noexcept {} - virtual ~MmapError() noexcept {} + MemoryError() noexcept {} + virtual ~MemoryError() noexcept {} virtual const char *what() const noexcept { - return "grnxx::MmapError"; + return "grnxx::MemoryError"; } }; -// This exception is thrown when memory allocation fails. -class MemoryError : public Exception { +// Thrown as an exception when a system call fails. +class SystemError : public Exception { public: - MemoryError() noexcept {} - virtual ~MemoryError() noexcept {} + SystemError(const Errno &code) noexcept : code_(code) {} + virtual ~SystemError() noexcept {} + const Errno &code() const noexcept { + return code_; + } virtual const char *what() const noexcept { - return "grnxx::MemoryError"; + return "grnxx::SystemError"; } + + private: + Errno code_; }; } // namespace grnxx -------------- next part -------------- HTML����������������������������... Download