|
Boost : |
From: Alan Bellingham (alan_at_[hidden])
Date: 2002-09-23 07:11:54
Peter Dimov:
>From: "Victor A. Wagner, Jr." <vawjr_at_[hidden]>
>> I understand, but it's a lot faster to do a "switch" on an int, than on a
>> const char* (another thing left out of the language)
>
>Why would you do a "switch" on an exception's error code?
Exactly - switch() is often a sign you can do something better. In the
case of the exception hierarchy, you'd use more specialised catch blocks
and make use of the dynamic type of the exception.
As I understood Vladimir, he was was after something like:
std::exception
|
...
|
rename::exception
|
-------------------------
| |
rename::not_found rename::different_media
In this case, he can catch a rename::different_media exception and do a
copy/delete, but just ignore any other one. It's probably cleaner than
catching a rename::exception, switching on a reason code in that
exception, and either rethrowing it or handling it depending on the
reason code.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk