Do we have an exception policy?

Asked by Arty

Do we have a policy what kind of exceptions we throw/catch? And if not, should we have one?

I noticed that in several places we just catch exceptions of the type WException. In many cases this is okay, and we ensure that we catch the exceptions that we throw ourselves here and not just anything. BUT this can also be problematic at some points, because not even all our own custom exceptions are inherited from WException. For example, the filesystem stuff has its own FileError and ZipOperationError exception types.

Should we try to inherit all our custom exception types from WException? (This might be non-trivial.)
Or should we just be more careful with catches?
What do you think?

Question information

Language:
English Edit question
Status:
Answered
For:
widelands Edit question
Assignee:
No assignee Edit question
Last query:
Last reply:
Revision history for this message
GunChleoc (gunchleoc) said :
#1

I think having a consistent policy is a good idea. Double-check if we're catching std::exception in WLApplication, then we'll be good in any case.

The practical thing about the wexception macro is that it parses the printf arguments.

Everything else should have a more local scope. I haven't seen what has been done in the file system parts, but if you want to change them to be more consistent, please do go ahead :)

Maybe they should all have a usage comment?

Can you help with this problem?

Provide an answer of your own, or ask Arty for more information if necessary.

To post a message you must log in.