File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

AssertionError

 
joshua antony
Ranch Hand
Posts: 117
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To discourage you from trying
to substitute an assertion for an exception, the AssertionError doesn't provide
access to the object that generated it. All you get is the String message.

Above is from K&B.
I am not able to understand it.
Can somebody please explain the same with some example
 
wise owen
Ranch Hand
Posts: 2023
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Programming With Assertions

Access to these objects would encourage programmers to attempt to recover from assertion failures, which defeats the purpose of the facility.
 
joshua antony
Ranch Hand
Posts: 117
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi wise,

Thanks for your reply.
My problem is basically with the line the AssertionError doesn't provide
access to the object that generated it


In the below code, the access to which object is not provided?
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic