Boost logo

Boost :

From: Rozental, Gennadiy (gennadiy.rozental_at_[hidden])
Date: 2003-02-14 12:21:44


> I've encountered a problem with exceptions in boost/test:
> Our project uses a base class for all our exceptions which
> cannot derive
> from std::exception.
>
> If such an exception is thrown, the message:
> Exception in "...": unknown type
> is printed out, which is not very helpful in locating the problem.
>
> Is there a way to specify an "exception handler", which can
> catch "our"
> exceptions and print something more useful?.

I could do something along following lines:

#include <iostream>
using namespace std;

void
unknown_exception_handler()
{
    try {
        throw;
    }
    catch( int i ) {
        cout << "int caught\n";
    }
}

int main()
{
    try {
        throw 1;
    }
    catch( ... ) {
        try {
            unknown_exception_handler();
        } catch( ... ) {
            cout << "unknown exception\n";
        }
    }
}

and provide a way to configure unknown_exception_handler.
Dave, do you have something different in mind?

Gennadiy.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk