Win a copy of Head First Go this week in the Go forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Liutauras Vilda
  • Bear Bibeault
  • Paul Clapham
  • Jeanne Boyarsky
Sheriffs:
  • Devaka Cooray
  • Junilu Lacar
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Ron McLeod
  • Tim Holloway
  • Claude Moore
  • Stephan van Hulst
Bartenders:
  • Winston Gutkowski
  • Carey Brown
  • Frits Walraven

What happens if an exception is not caught?  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What happens if an exception not caught?
 
Marshal
Posts: 63478
207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It propagates back up the stack, collecting details of every line in the path from where it was thrown to the main() method, until it runs out of places to go. Then the thread the exception was thrown from is terminated and a stack trace printed.
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes you can use 'try'  block  followed by finally block to avoid exception caught event  but any runtime or ( unchecked) exception if occurs will not be logged  you can use throws clause to skip  try-catch in some cases like IOException or just extend Exception for that class you declared.
 
Campbell Ritchie
Marshal
Posts: 63478
207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
SR,, welcome to the Ranch
 
Ranch Hand
Posts: 136
5
MS IE Notepad Suse
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The explanation lies in the documentation to java.lang.Thread: each Thread has an UncaughtExceptionHandler wich is responsible for exactly this situation: when an Exception is thrown in a Thread wich is not caught elsewhere.
The usual behaviour is to print a stack-trace to standard error and terminate the Thread.

I'm sure there is something to be found in the big index about that.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It leads to the termination of the program within which through when an uncaught exception results in the uncaughtException() method of the thread’s ThreadGroup, it invokes.
 
Campbell Ritchie
Marshal
Posts: 63478
207
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
AA: I hope you didn't write that tutorial, because I don't think it is a good tutorial, I am afraid. Please avoid simply linking to a tutorial in your posts.
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
ScroogeXHTML 8.2 - easy to use RTF to HTML converter library
https://coderanch.com/t/707504/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!