6

Is there any method to handle/catch all exceptions thrown by a Java application, without spamming costly try{}catch(Exception e){} statements everywhere?

For example, PHP has the function set_error_handler().

Back story - Despite tough testing, sometimes bugs can get through, and users are always less than cooperative with helping to fix these. Ideally, I'd like to hook the application up to a web service facility that can keep track of any stack traces thrown by a user's application.

honk
  • 9,137
  • 11
  • 75
  • 83
Ben Poulson
  • 3,368
  • 2
  • 17
  • 26
  • 6
    I think this is what you're looking for: http://stackoverflow.com/questions/1548487/java-global-exception-handler – d0ggy Mar 17 '14 at 17:30

1 Answers1

6

Perhaps you're looking for Thread.setDefaultUncaughtExceptionHandler() ?

Eric Stein
  • 13,209
  • 3
  • 37
  • 52