susumu.yata
null+****@clear*****
Tue Aug 13 17:12:00 JST 2013
susumu.yata 2013-08-13 17:12:00 +0900 (Tue, 13 Aug 2013) New Revision: 53681df0d3112854b0ca1ee74eb1c55783573f7d https://github.com/groonga/grnxx/commit/53681df0d3112854b0ca1ee74eb1c55783573f7d Message: Add grnxx::StandardError to wrap std::exception. Modified files: lib/grnxx/exception.hpp lib/grnxx/map/pool.cpp Modified: lib/grnxx/exception.hpp (+16 -0) =================================================================== --- lib/grnxx/exception.hpp 2013-08-13 14:26:15 +0900 (bc3681a) +++ lib/grnxx/exception.hpp 2013-08-13 17:12:00 +0900 (f831500) @@ -59,6 +59,22 @@ class MemoryError : public Exception { } }; +// Thrown as as exception when an exception generated by the standard library +// is caught. +class StandardError : public Exception { + public: + StandardError(const std::exception &exception) noexcept + : exception_(exception) {} + virtual ~StandardError() noexcept {} + + virtual const char *what() const noexcept { + return exception_.what(); + } + + private: + const std::exception &exception_; +}; + // Thrown as an exception when a system call fails. class SystemError : public Exception { public: Modified: lib/grnxx/map/pool.cpp (+4 -3) =================================================================== --- lib/grnxx/map/pool.cpp 2013-08-13 14:26:15 +0900 (65b190e) +++ lib/grnxx/map/pool.cpp 2013-08-13 17:12:00 +0900 (aee3ea4) @@ -17,6 +17,8 @@ */ #include "grnxx/map/pool.hpp" +#include <exception> + #include "grnxx/exception.hpp" #include "grnxx/geo_point.hpp" #include "grnxx/intrinsic.hpp" @@ -354,10 +356,9 @@ void Pool<T>::refresh_pool() { try { // TODO: Time must be added. queue_.push(std::move(new_pages)); - } catch (...) { + } catch (const std::exception &exception) { GRNXX_ERROR() << "std::queue::push() failed"; - // TODO: Wrap an error. - throw; + throw StandardError(exception); } } table_ = new_table; -------------- next part -------------- HTML����������������������������... Télécharger