[
Date Prev][
Date Next][
Thread Prev][
Thread Next][
Date Index][
Thread Index]
Re: New API & Exceptions
Below is quick scetch of what it could look like.
I'm not using typedefs, in case someone wants to
differentiate for whatever reason. If you know of
any more specific standard exceptions that could
be used, please update the list.
class IllegalArgumentException: public std::invalid_argument
class NumberFormatException: public std::invalid_argument
class IllegalStateException: public std::runtime_error
class UnsupportedEncodingException: public std::runtime_error
class ServletException: public std::runtime_error
class IOError: public std::ios_base::failure
I think this covers all exceptions referenced in your public APIs.
Krzysztof Rzymkowski wrote:
> Ilya A. Volynets-Evenbakh wrote:
>> On one hand using standard C++ exceptions
>> where possible makes sense. On the other hand,
>> it introduces naming inconsistencies, because
>> some exceptions have no analogues (think
>> IllegalStateException when setting headers in
>> committed output stream). I think best approach
>> is combined one: simply derive from standard exceptions
>> where possible, (or even create typedefs), and still
>> throw by Java name. This way both C++ programmers,
>> and those switching from Java will have what they need.
>> Side benefit of having all Java exception names available
>> is easier possibility of automagic Java servlet to C++ servlet
>> translation (I know it's far off goal, but one day we might
>> come up with the tool ;-)
>>
>
> You're right. Deriving from std or typedefing is a good idea. I'm for it.
>
>
--
Ilya A. Volynets-Evenbakh
Total Knowledge. CTO
http://www.total-knowledge.com