[Boost-bugs] [Boost C++ Libraries] #9796: std::system_error cannot be catched after is rethrown with boost::rethrow_exception()

Subject: [Boost-bugs] [Boost C++ Libraries] #9796: std::system_error cannot be catched after is rethrown with boost::rethrow_exception()
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2014-03-20 08:32:25


#9796: std::system_error cannot be catched after is rethrown with
boost::rethrow_exception()
------------------------------+----------------------------
 Reporter: anonymous | Owner: emildotchevski
     Type: Bugs | Status: new
Milestone: To Be Determined | Component: exception
  Version: Boost 1.54.0 | Severity: Problem
 Keywords: |
------------------------------+----------------------------
 boost::rethrow_exception() loses information about the system_error
 exception type. See the
 following example code, which when compiled with g++ --std=c++11, displays
 ''exception caught'' instead of ''system error caught'':


 {{{
 #include <iostream>
 #include <system_error>
 #include <boost/exception/all.hpp>


 void do_something()
 {
   try
   {
     // let's assume the following exception is thrown inside some
     // system library function...
     throw std::system_error(EDOM, std::system_category());
   }
   catch (...)
   {
     boost::rethrow_exception(boost::current_exception());
   }
 }
 int main()
 {
    try
    {
     do_something();
    }
    catch (const std::system_error & ex)
    {
       std::cout << "system error caught\n";
    }
    catch (const std::exception & ex)
    {
       std::cerr << "exception caught\n";
    }
    return 0;
 }

 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/9796>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:15 UTC