123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- #ifndef BOOST_INTERPROCESS_EXCEPTIONS_HPP
- #define BOOST_INTERPROCESS_EXCEPTIONS_HPP
- #if (defined _MSC_VER) && (_MSC_VER >= 1200)
- # pragma once
- #endif
- #include <boost/interprocess/detail/config_begin.hpp>
- #include <boost/interprocess/detail/workaround.hpp>
- #include <boost/interprocess/errors.hpp>
- #include <stdexcept>
- #include <new>
- namespace boost {
- namespace interprocess {
- class interprocess_exception : public std::exception
- {
- public:
- interprocess_exception(const char *err)
- : m_err(other_error)
- {
- try { m_str = err; }
- catch (...) {}
- }
- interprocess_exception(const error_info &err_info, const char *str = 0)
- : m_err(err_info)
- {
- try{
- if(m_err.get_native_error() != 0){
- fill_system_message(m_err.get_native_error(), m_str);
- }
- else if(str){
- m_str = str;
- }
- else{
- m_str = "boost::interprocess_exception::library_error";
- }
- }
- catch(...){}
- }
- virtual ~interprocess_exception() throw(){}
- virtual const char * what() const throw()
- { return m_str.c_str(); }
- native_error_t get_native_error()const { return m_err.get_native_error(); }
-
- error_code_t get_error_code() const { return m_err.get_error_code(); }
-
- private:
- error_info m_err;
- std::string m_str;
-
- };
- class lock_exception : public interprocess_exception
- {
- public:
- lock_exception()
- : interprocess_exception(lock_error)
- {}
- virtual const char* what() const throw()
- { return "boost::interprocess::lock_exception"; }
- };
- class bad_alloc : public interprocess_exception
- {
- public:
- bad_alloc() : interprocess_exception("::boost::interprocess::bad_alloc"){}
- virtual const char* what() const throw()
- { return "boost::interprocess::bad_alloc"; }
- };
- }
- }
- #include <boost/interprocess/detail/config_end.hpp>
- #endif
|