in reply to Re: Enforcing exception catching
in thread Enforcing exception catching

The problem is that there are many programs using the libraries and I don't know which ones do not handle exceptions correctly. (Yet, I will be doing an audit). Placing all top-level calls in try{} blocks seems to be fixing symptoms, not the problem.

Replies are listed 'Best First'.
Re: Re: Re: Enforcing exception catching
by stvn (Monsignor) on Feb 12, 2004 at 17:30 UTC
    Placing all top-level calls in try{} blocks seems to be fixing symptoms, not the problem.

    It does only fix one symptom, but I never meant that to be a fix for the whole problem (sorry if i wasn't clear). IMO if you have code that throws an exception anywhere at all, your top level call should always have a catch block. You should never let an exception kill your program, you should always catch them so that you can clean up resources and such, or at a minimum log the exception and a stack trace.

    Exceptions are a huge improvement over standard return value error checking not just because they allow you to centralize your error handling (sometimes much further up the call chain), but because they (the exception itself) can carry with it valuable information, like stack traces and contextual information from the call site. This kind of info is invaluable when trying to debug an error, and lightyears ahead of the old standard printf debugging technique.

    -stvn