1

Possible Duplicate:
Java: Global Exception Handler

I thought of something like this:

public static void main(String[] args) {
  try {
    startOfMyProg();
  } catch (RuntimeException e) {
     log.error(e.toString());
     // Maybe rethrow it so i can see it in the console?
  }
}

It's a simple solution, i know. Maybe someone knows a better one?

regards && tia noircc

Community
  • 1
  • 1
noircc
  • 650
  • 10
  • 28
  • 2
    Well you can get better results buy using just `Exception` or `Throwable`. Some exceptions will get past runtime exception. – Thihara Jun 21 '12 at 08:29

1 Answers1

3

I would

} catch (Throwable e) {
    log.error("Uncaught exception", e); // prints the stack trace.
Peter Lawrey
  • 525,659
  • 79
  • 751
  • 1,130