Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Mr Cucumber

Catching errors during error handling

This topic is 5777 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Right now my application works like this. The only way to shutdown the application is by throwing a Shutdown() or an Error(). The Error class is derived from the Shutdown class which allows me to only catch a Shutdown. Lets say the application starts the shutdown process in the catch part, and an Error occurs? What I am supposed to do with that throw, use another try-catch inside the other catch? And then if an error occurs in that catch what about then? Basically what I want is that the application does a normal good shutdown in case of an error. But the problem is if another error occurs when the error has been caught and the shutdown process has started.

Share this post


Link to post
Share on other sites
Advertisement
You shutdown by throwing an error?

Exceptions are supposed to be used for exceptional cicumstances - it is not exceptional for someone to want to shut down your sofware.

Have you derived Error from the Shutdown class purely so that you only have to have one catch statement ie catch(Shutdown& e). That''s not a good reason for setting up a hierarchy.

Actually a thought - it''s just starting to nag at me - are you a java programmer?

Share this post


Link to post
Share on other sites
I think he is using Shutdown to indicate an unrecoverable error that requires termination of the application. The only problem with that is that the caller should make that determination.

Generally an error handler should not generate an error because it hides the original error. That isn''t to say you don''t throw an error, but rather you throw the original or a reinterpretation of the original, i.e. a more descriptive error. You have to use your judgement though. You could run into an unrelated error such as an inability to write to the log that is a higher priority problem than the original error, i.e. the problem with the log needs to be fixed first. You can use an error class that is a container so that you don''t have to decide which of multiple errors to report.

Share this post


Link to post
Share on other sites
You are probably right that I should not exit the application with an exception, and no I''m not a Java programmer (probably just bad programming habits).

Its actually not the error handler itself that can throw an error. When the error is caught I start the shutdown process.
Since there can be quite a lot of code in the shutdown process (for example save states to a file, close window and more) I need to check for errors during the shutdown process.

Perhaps the best way is to remove the shutdown process from the error handling and just do the absolutely necessary when the error is caught.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!