17 #ifndef JUBATUS_CORE_COMMON_EXCEPTION_HPP_
18 #define JUBATUS_CORE_COMMON_EXCEPTION_HPP_
29 #include "jubatus/util/lang/shared_ptr.h"
30 #include "jubatus/util/lang/demangle.h"
42 inline std::string
to_string(
const error_errno& info) {
44 #if defined(__linux__)
45 std::string msg(strerror_r(info.
value(), buf,
sizeof(buf)));
46 #elif defined(__sparcv8) || defined(__sparcv9) || defined(__APPLE__)
47 strerror_r(info.
value(), buf,
sizeof(buf));
53 jubatus::util::lang::lexical_cast<std::string>(info.
value()) +
")";
68 #define JUBATUS_ERROR_FUNC \
69 jubatus::core::common::exception::error_at_func(__PRETTY_FUNCTION__)
71 #define JUBATUS_ERROR_FUNC \
72 jubatus::core::common::exception::error_at_func(__func__)
75 #define JUBATUS_CURRENT_ERROR_INFO() \
76 jubatus::core::common::exception::error_at_file(__FILE__) \
77 << jubatus::core::common::exception::error_at_line(__LINE__) \
78 << JUBATUS_ERROR_FUNC << jubatus::core::common::exception::error_splitter()
79 #define JUBATUS_EXCEPTION(e) e << \
80 jubatus::core::common::exception::exception_thrower_binder_type() \
81 << JUBATUS_CURRENT_ERROR_INFO()
84 typedef jubatus::util::lang::shared_ptr<exception_thrower_base>
87 typedef std::vector<jubatus::util::lang::shared_ptr<error_info_base> >
97 virtual exception_thrower_ptr
thrower()
const = 0;
99 template<
class Exception>
102 jubatus::util::lang::shared_ptr<error_info_base> info);
104 std::string
name()
const throw () {
108 typeid(*this).name());
114 virtual const char*
what()
const throw () {
127 template<
class Exception>
130 jubatus::util::lang::shared_ptr<error_info_base> info) {
131 e.info_list_.push_back(info);
135 template<
class Exception,
class Tag,
class V>
141 jubatus::util::lang::shared_ptr<error_info_base>(
145 template<
class Exception>
148 jubatus::util::lang::shared_ptr<error_info_base> info) {
162 template<
class Exception>
183 template<
class Exception>
197 *(static_cast<const Exception*>(
this))));
210 template<
class Exception>
225 const char*
what()
const throw () {
226 return "unknown exception";
239 const char*
what()
const throw () {
240 return what_.c_str();
247 template<
class Exception>
256 exception_thrower_ptr ptr;
260 }
catch (
const std::bad_alloc& e) {
262 }
catch (
const std::bad_cast& e) {
264 }
catch (
const std::bad_exception& e) {
266 }
catch (
const std::bad_typeid& e) {
268 }
catch (
const std::domain_error& e) {
270 }
catch (
const std::invalid_argument& e) {
272 }
catch (
const std::length_error& e) {
274 }
catch (
const std::out_of_range& e) {
276 }
catch (
const std::logic_error& e) {
278 }
catch (
const std::range_error& e) {
280 }
catch (
const std::overflow_error& e) {
282 }
catch (
const std::underflow_error& e) {
284 }
catch (
const std::ios_base::failure& e) {
286 }
catch (
const std::runtime_error& e) {
290 }
catch (
const std::exception& e) {
308 const char*
what()
const throw () {
309 return "config_not_set";
317 std::string(
"unsupported method (") + n +
")") {
353 std::string(
"invalid parameter (expected: ") + expected +
")") {
361 #endif // JUBATUS_CORE_COMMON_EXCEPTION_HPP_
exception_thrower_ptr thrower_
const Exception & add_info(const Exception &e, jubatus::util::lang::shared_ptr< error_info_base > info)
bad_storage_type(const std::string &n)
std::string to_string(const error_errno &info)
virtual void throw_exception() const =0
error_info< struct error_api_func_, std::string > error_api_func
const Exception & operator<<(const Exception &e, const error_info< Tag, V > &info)
std::vector< jubatus::util::lang::shared_ptr< error_info_base > > error_info_list_t
argv_error(const std::string &n)
void bind_thrower(exception_thrower_ptr thrower) const
not_found(const std::string &n)
unsupported_method(const std::string &n)
error_info_list_t error_info() const
error_info< struct error_file_name_, std::string > error_file_name
exception_thrower_ptr thrower() const
error_info< struct error_at_line_, int > error_at_line
const char * what() const
virtual ~exception_thrower_base()
exception_thrower_impl(const Exception &e)
const char * what() const
error_info_list_t info_list_
virtual exception_thrower_ptr thrower() const =0
virtual const char * what() const
jubatus::util::lang::shared_ptr< exception_thrower_base > exception_thrower_ptr
virtual ~jubatus_exception()
error_info< struct error_at_file_, std::string > error_at_file
std::string exception_class_name_
error_info< struct error_message_, std::string > error_message
exception_thrower_ptr current_std_exception(const Exception &e)
runtime_error(const std::string &what)
membership_error(const std::string &n)
friend const Exception & add_info(const Exception &e, jubatus::util::lang::shared_ptr< error_info_base > info)
error_info< struct error_errno_, int > error_errno
invalid_parameter(const std::string &expected)
exception_thrower_ptr get_current_exception()
error_info< struct error_at_func_, std::string > error_at_func
const char * what() const
exception_thrower_impl & operator=(const exception_thrower_impl &)
std::string diagnostic_information(bool display_what=false) const
error_info< struct error_splitter_, void > error_splitter
void throw_exception() const