Re: catch all program errors...
- From: "Philipp Leitner" <philipp.leitner@xxxxxx>
- Date: 31 May 2006 13:13:41 -0700
you can simply add a Try/Catch Block to your main method:
try {
// what you usually do in main
} catch (Exception e) {
// your logging code
}
Whether you /should/ do that is a completely different story, since you
are then surpressing severe program errors (what does not make them
less severe, but harder to detect). For example the program might throw
your NullPointerException in the middle of some transaction with the
user; then the exception is caught, and the user might never notice
that the transaction was not finished. The application might be in an
undefined error state then.
I would think about the risks first.
/philipp
tiewknvc9 wrote:
Im trying to find a quick way to catch all of my programs errors. These
would be the last remaining errors that are not currently caught in my
application,
for instance it would be a nullpointer exception - one that I never
expected to occur, so it was not caught. What I would like to do is to
catch any and all exceptions and log them in some way so that I can
update the program, and alert the user to the fact that an error had
occurred. The later I get, the catching all uncaught errors I am lost
with.
Any advice?
Thanks
.
- Follow-Ups:
- Re: catch all program errors...
- From: Daniel Dyer
- Re: catch all program errors...
- References:
- catch all program errors...
- From: tiewknvc9
- catch all program errors...
- Prev by Date: How to Compile JNI program on windows/cygwin
- Next by Date: Re: Why JavaEE / EJB3?
- Previous by thread: catch all program errors...
- Next by thread: Re: catch all program errors...
- Index(es):
Relevant Pages
|