
-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Andreas Huber Sent: Tuesday, July 18, 2006 10:05 PM Subject: Re: [boost] Exception Visitor
// Untested code #include <stdexcept>
// Generic handler function void HandleException() { try { throw; } catch (const std::logic_error &) { // whatever } catch (const std::exception &) { // whatever } }
int main() { try { // throwing code } catch (...) { HandleException(); }
return 0; }
If you forget to handle a relevant exception in HandleException, is your debugger able to show you the 'right' backtrace (i.e. where the exception really occurred)? I don't think the op's idea has that problem. cheers, aa -- Andreas Ames | Programmer | Comergo GmbH | Voice: +49 69 7505 3213 | ames AT avaya DOT com

Ames Andreas wrote:
If you forget to handle a relevant exception in HandleException, is your debugger able to show you the 'right' backtrace (i.e. where the exception really occurred)? I don't think the op's idea has that problem.
Really? I don't see how the OPs code is any different in this regard. To quote the OP: <OP>
try { //Some code that might throw exceptions, such as: throw std::logic_error("A sample logic error."); } catch(...) { //Magic happens here. catcher(my_exception_handler()); //This prints out "my_exception_handler::operator()(std::logic_error&)" } </OP>
How does catcher find out what exception was thrown? It seems it must use the same idiom that ::HandleException() uses, i.e. throw; inside a try block. Once you do that, most debuggers won't be able to show the original stack trace. Regards, -- Andreas Huber When replying by private email, please remove the words spam and trap from the address shown in the header.

Andreas, On 7/19/06, Andreas Huber <ahd6974-spamgroupstrap@yahoo.com> wrote:
How does catcher find out what exception was thrown? It seems it must use the same idiom that ::HandleException() uses, i.e. throw; inside a try block.
Catcher does use the "throw inside a try block" idiom (is there a better name for that?). Once you do that, most debuggers won't be able to show the
original stack trace.
Visual Studio .NET 2003 (and, I imagine, .NET 2005) do show you the original stack trace. Jeremy
participants (3)
-
Ames Andreas
-
Andreas Huber
-
Jeremy Day