Re: [boost] [exception] ostringstream like

exception are just here to gather and carry diagnostic info, not full fledged error message If you throw a bad_alloc, you don't need to add a full fledged error message, I agree that the localization and the exception type is sufficient. When you throw a logic_error, more the message is clear, precise and detailed better it is.
may fail to allocate the needed memory for the string and stream, thus maskign the initial exception with some bad_alloc. I agree for bad_alloc exception, but as before you don't really need a message in this particular case. If you throw a logic_error, you don't have more chance to encounter a bad_alloc than everywhere in your application.

On 16/08/10 14:01, fabien.castan@free.fr wrote:
exception are just here to gather and carry diagnostic info, not full fledged error message
If you throw a bad_alloc, you don't need to add a full fledged error message, I agree that the localization and the exception type is sufficient.
No, I mean that if you do advanced string manipulation in the exception itself, you may screw up, adn cause a bad_alloc beign thrown and masking your own exception.
When you throw a logic_error, more the message is clear, precise and detailed better it is.
Just make your own, informative exception type deriving from logic_error.
participants (2)
-
fabien.castan@free.fr
-
joel falcou