ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> boost
boost
Re: [boost] Re: Review: Boost Test Library
by David Abrahams other posts by this author
Feb 13 2001 11:53PM messages near this date
Re: [boost] Re: Review: Boost Test Library | Re: Review: Boost Test Library
Bill,

the try { throw; } idiom is a great way to centralize exception
type-detection (e.g. for reporting) code, but you're right that MSVC has a
problem with multiple destruction in this case. That's I always make sure my
exception classes are resilient to multiple-destruction when targeting MSVC.

-Dave

----- Original Message -----
From: <williamkempf@[...]..> 
To: <boost@[...].com> 
Sent: Tuesday, February 13, 2001 4:57 PM
Subject: [boost] Re: Review: Boost Test Library


>  Just a thought to spark others creativity...
> 
>  I've been thinking a bit about the desire for catch_exceptions() to
>  be able to handle registered exception types (during my breaks from
>  documenting the BTL, which should be done in a day or two for those
>  who are helping me finalize this before submitting), and a trick
>  suggested on a programming site I read in the past came to mind
>  (sorry, I can't give exact credit here). Error handling functions
>  can be registered and called from catch blocks by using the following
>  idiom:
> 
>  bool handle_my_error_types()
>  {
>  try
>  {
>  throw; // re-throw the last exception
>  }
>  catch (my_specific_error_type err)
>  {
>  // handle the error
>  return true; // we handled the error
>  }
>  catch (...)
>  {
>  return false; // we didn't handle the error
>  }
>  }
> 
>  void example()
>  {
>  try
>  {
>  // some code that throws
>  }
>  catch (...)
>  {
>  if (handle_my_error_types())
>  cout << handled << endl;
>  else
>  cout << unknown exception type << endl;
>  }
>  }
> 
>  I think that this idiom could be used to allow test programs
>  to push handlers for specific exception types that they used onto
>  a handler stack that would be used by catch_exceptions(). This
>  should allow for very specific reports about what exceptions are
>  caught by the test framework, even though the framework is not aware
>  of library defined exception types.
> 
>  The one caveat is that (at the time I found this idiom at least) VC++
>  couldn't handle this (it tries to destruct the exceptions multiple
>  times!).
> 
>  Any thoughts or comments on the idea?
> 
>  Bill Kempf
> 
> 
> 
> 
Thread:
Jens Maurer
Ed Brey
Beman Dawes
Jens Maurer
Beman Dawes


Jens Maurer

Jens Maurer
David Abrahams
David Abrahams

Mark Rodgers

Kevlin Henney

Kevlin Henney

Ronald Garcia

Mark Rodgers
Ed Brey
David Abrahams

David Abrahams
David Abrahams
Beman Dawes
Ed Brey

Jens Maurer
Beman Dawes

Ed Brey

Privacy Policy | Email Opt-out | Feedback | Syndication
© ActiveState Software Inc. All rights reserved