First of all, you shouldn't need to wrap all calls to exception throwing functions in a try/catch block. Doing that is not much different that checking return error codes. You should catch exceptions where you can appropriately deal with them, not where they are being thrown. There is no use in catching an exception if you can't do anything useful with it. But to not catch an exception when you can deal with it (and possibly save the program from die-ing) is a design-time error not a compile/run-time error.
I agree too with adrianh, you probably need some static code analysis, and then have a talk about exceptions with all your developers to agree upon a method of usage. Consistent usage/paradigms is very important among groups of developers IMHO.
Secondly, If your program is throwing uncaught exceptions and die-ing, then wrap the main entry point in a try block. This will allow you to at least catch these exceptions and print out a stack trace before your program dies. Of course this may not be the best place to handle your exceptions, but at the very least you can do something rather than just letting things die.
Of course I am speak of Perl, not Java (which IMHO has got alot of language design problems). If you want a non-Perl reference to how to handle exceptions, don't look at Java instead look at a language like Ada. Java was made for web-applets, Ada was made by the U.S. Dept. of Defense for missle guidance systems (where reliability and smart error handling is key).
-stvnIn reply to Re: Enforcing exception catching
by stvn
in thread Enforcing exception catching
by dmitri
For: | Use: | ||
& | & | ||
< | < | ||
> | > | ||
[ | [ | ||
] | ] |