|
Boost : |
From: Yitzhak Sapir (yitzhaks_at_[hidden])
Date: 2002-11-04 03:48:13
On Sun, 3 Nov 2002, Darin Adler wrote:
> On Sunday, November 3, 2002, at 02:00 PM, Beman Dawes wrote:
>
> > Surely your debugger allows you to trap the exception at the point it
> > is thrown, so that the stack (and everything else) at that point is
> > available for inspection? Isn't that equivalent to getting a core
> > dump, yet preserves the benefits of exceptions in non-debugging
> > environments?
>
> In the programming environments I use, the debugger allows me to either
> trap all exceptions at the point they are thrown, or none at all. I
> don't know of any environment that lets you express which exceptions
> are expected and which are not.
>
> The problem is that during normal operation of most of my programs,
> occasional exceptions are thrown and caught by code that expects them.
> It's very hard to set up an environment where any exception that
> indicates a programming error will drop into the debugger, but any
> exception that simply indicates an unusual runtime condition will not.
>
> This is a reason I strongly prefer asserts to exceptions to indicate
> programming errors.
On Visual Studio, I can put a breakpoint in the constructor of an
exception by class (such as std::logic_error::logic_error()) (or at the
throw point, if I know from where it will be thrown). It's also possible
to write a specialized assert macro that does something of the form:
if (!assert_condition) {
if (::IsDebuggerPresent()) ::DbgBreakpoint();
else throw exception;
}
It's possible to make it more complex and display a dialog window like
Visual Studio normally does.
Maybe something like that could be added to the boost utility library?
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk