catch(...) in thread_proxy

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

catch(...) in thread_proxy

Jeremy Stanley
I find the catch(...) in thread_proxy to be a real nuisance.  The only
thing I
can do to prevent threads from silently slipping away is to put a
catch(...)
inside my thread procedure, but when this is hit I have no idea what the
exception is or where it was thrown.  I could configure the debugger
(msvc71) to
break whenever an exception is thrown, but then I have to wade through
handled
exceptions in order to find the real error.

There was a discussion on this subject about eight months ago where the
consensus seemed to be get rid of the catch(...)--any progress on this
since
then?  I notice the catch(...) is still present in CVS, which isn't
encouraging.

As a refresher, this approach won't help...

try
{
  thread_proc();
}
catch(...)
{
  exception_filter();  // ... because I don't have a stack trace here.
}

This sort of approach could be okay though:

if ( swallow_exceptions )
{
  try { thread_proc(); } catch(...) { whatever(); }
}
else
{
  thread_proc();
}

If swallow_exceptions were on by default, it wouldn't change behavior
unless the
programmer asked for it, perhaps using an optional parameter in the
thread and
thread_group constructors.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: catch(...) in thread_proxy

Bronek Kozicki
Jeremy Stanley wrote:

> As a refresher, this approach won't help...
>
> try
> {
>   thread_proc();
> }
> catch(...)
> {
>   exception_filter();  // ... because I don't have a stack trace here.
> }

sorry to butt in, but could you pls. explain why? I just suggested something
similar in another thread (and mailing list). exception_filter would look like:

exception_filter()
{
   try {throw;}
   catch(std::exception& e)
   {//...
   }
   catch(whateverelse& e)
   {//...
   }
   // .. etc
}


B.
_______________________________________________
Boost-users mailing list
[hidden email]
http://lists.boost.org/mailman/listinfo.cgi/boost-users