Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Application exception

 
Tmmet Johnson
Ranch Hand
Posts: 56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I throw an application exception as below in my catch blocks.
Does this catch block will miss the stacktrace exception when finally caught in the caller method?
Could anyone please let me know?Thanks in advance,

[ Edited to include code tags - Paul Sturrock ]
[ November 01, 2006: Message edited by: Paul Sturrock ]
 
Jesper de Jong
Java Cowboy
Saloon Keeper
Posts: 15288
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are throwing a new exception in the catch block. The caller that catches the ValidationFailedException will ofcourse only be able to see the stacktrace of the ValidationFailedException, and not the stacktrace of the original DataValidationException.

You could have found out this for yourself by writing a small test program.
 
Joanne Neal
Rancher
Posts: 3742
16
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can add the original exception to your new exception, either by adding a constructor that accepts a Throwable as an argument and calls the appropriate super class constructor or by calling the initCause() method.
Then the code that catches your exception can retrieve the original exception using the getCause() method.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not an advanced question. Moving...
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic