Home » U++ Library support » U++ Widgets - General questions or Mixed problems » how to input an int into std::string? and an exception question
Re: how to input an int into std::string? [message #13368 is a reply to message #13362] |
Thu, 03 January 2008 13:18 |
|
tvanriper
Messages: 85 Registered: September 2007 Location: Germantown, MD, USA
|
Member |
|
|
When you throw an exception, if you have no way to catch that exception, it will crash your program.
That's actually kind of the point behind exceptions.
If you never want your program to crash due to an exception, but want it to die gracefully, you have to provide some way to handle all exceptions. Sometimes, this is accomplished in main with something like:
int main( int argc, char** argv )
{
try
{
millions_of_functions();
even_more_functions();
maybe_yet_more_functions();
}
catch( ... )
{
// Some error handling routine here... like maybe:
std::cerr << "Something catastrophic happened." << std::endl;
}
}
So, based on what I'm reading in your message, I do not see the nature of your problem. It looks to me that your program should be crashing, since you're asking it to do so.
Generally, the folks experienced with C++ that I've talked to seem to agree that exceptions should be used in very rare cases, and ought to be avoided if possible. You might only use exceptions for truly exceptional situations, where you can see that the system will have a serious problem that destabilizes memory or registers, and want to clearly indicate where the problem occurred so you can fix it more easily.
If you can, you should try to indicate most error conditions through other means, perhaps through an error state, return code, or something you change in a parameter.
|
|
|
Goto Forum:
Current Time: Wed May 15 17:58:13 CEST 2024
Total time taken to generate the page: 0.02570 seconds
|