Is it possible to handle all Errors in Java? -


i know error throwable (so can handled) , error handling isn't best practice suppose have requirement catch error.

it possible in general? mean errors can appear in daemon threads? crash jvm , won't know it.

and can miss error if surround main(string... args) try-catch?

you can catch uncaught exceptions via thread.setuncaughtexceptionhandler()

set default handler invoked when thread abruptly terminates due uncaught exception, , no other handler has been defined thread.

uncaught exception handling controlled first thread, thread's threadgroup object , default uncaught exception handler. if thread not have explicit uncaught exception handler set, , thread's thread group (including parent thread groups) not specialize uncaughtexception method, default handler's uncaughtexception method invoked.

whether that's idea question (!). may want clear resources, shut down connections etc., log issue and/or alert user. if have critical issues outofmemoryerrors there's little else can do.


Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -