Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Can we throw assertion error explicitily

 
ramesh maredu
Ranch Hand
Posts: 210
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a query regarding the statement mentioned below, this is taken from master exam that i downloaded.

Never throw assertion error explicitly


the answer says above statement is incorrect.But i feel we should not throw it explicitly.
 
Poornima Sharma
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, we can throw Its just like runtime exception (Every Error) you can catch it if you want. If you dont want to catch then it will be propogated upward.
 
ramesh maredu
Ranch Hand
Posts: 210
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I know we can throw it like any other exception but is it proper way of doing.
[ September 30, 2008: Message edited by: ramesh maredu ]
 
Christophe Verré
Sheriff
Posts: 14691
16
Eclipse IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Was the question "Can we throw assertion error explicitily ?", or "Is it a good practice to throw an assertion error ?".
 
ramesh maredu
Ranch Hand
Posts: 210
Eclipse IDE Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the question was "what are true?" the statement i mentioned was one option among five.

will there be any specific wording to indicate whether it is legal or proper?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic