aspose file tools*
The moose likes Java in General and the fly likes Application exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Java » Java in General
Bookmark "Application exception" Watch "Application exception" New topic
Author

Application exception

Tmmet Johnson
Ranch Hand

Joined: Nov 03, 2004
Posts: 56
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

Joined: Aug 16, 2005
Posts: 14269
    
  21

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.


Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 8 API documentation
Joanne Neal
Rancher

Joined: Aug 05, 2005
Posts: 3669
    
  15
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.


Joanne
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

Not an advanced question. Moving...


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Application exception