Win a copy of TensorFlow 2.0 in Action this week in the Artificial Intelligence and Machine Learning 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
  • Paul Clapham
  • Bear Bibeault
  • Jeanne Boyarsky
Sheriffs:
  • Ron McLeod
  • Tim Cooke
  • Devaka Cooray
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Jj Roberts
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • salvin francis
  • Scott Selikoff
  • fred rosenberger

Throwing a Throwable

 
Ranch Hand
Posts: 209
13
VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Running from the command line results in a message that there is an Exception:



But, I didn't throw an Exception, I threw a Throwable. So, I wondered if the act of throwing a Throwable caused the jvm to throw an Exception and if so, of what type. However, that can't be true either, since any Exception would have been caught.

At this stage in a program's life, is it pointless attempting to distinguish between the two, or is there some subtlety to be understood here?




 
Saloon Keeper
Posts: 12442
269
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's just the message that the JVM prints out. 'Exception' probably just reads nicer than 'throwable'.

Yes, you should distinguish between the two, even if the message doesn't. Throwable includes critical errors that you probably shouldn't catch.
 
Richard Hayward
Ranch Hand
Posts: 209
13
VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Stephan.
 
Saloon Keeper
Posts: 22679
153
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think that this is actually a grammatical problem. The word "Exception" in the message means "An exception was thrown", not that specifically a "java.lang.Exception" was thrown. Both checked and unchecked Exceptions and Throwable are all exceptions in the abstract sense of the word.

And in the fundamental mechanisms which handle them.
 
Richard Hayward
Ranch Hand
Posts: 209
13
VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Tim Holloway wrote:I think that this is actually a grammatical problem. The word "Exception" in the message means "An exception was thrown", not that specifically a "java.lang.Exception" was thrown.


ok. There is a similar circumstance if I attempt to compile code where I throw a Throwable that's neither caught or declared.


The unreported Throwable is described as an exception, not an Exception (with an upper case E).

 
author
Posts: 23887
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Richard Hayward wrote:
The unreported Throwable is described as an exception, not an Exception (with an upper case E).



Perhaps ... In the first case, the word is at the beginning of the sentence. And in the second case, it is not. Words at the beginning of sentences tend to be capitalized....

Henry
 
I will suppress my every urge. But not this shameless plug:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic