aspose file tools*
The moose likes Java in General and the fly likes Java Exception Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "Java Exception" Watch "Java Exception" New topic
Author

Java Exception

Samy Ganou
Greenhorn

Joined: Oct 05, 2009
Posts: 28
Hello ,

I want to have some best practices that concern java exception handling.
I have this situation:

ServiceA use the api apiB

the apiB has methods that throw many type of exception,
methodB1() throws ExceptionB1
methodB2() throws ExceptionB2

On the serviceA I have :
some methods : methodA1() , methodA2() .. these method make calls to methodB1() .. methodBx()
So we have to catch their exceptions.
I have alse a general method
doProcessA() that calls methodA1() .. methodAx()
I want that all methods methodAx() throw one ExceptionA , because i want to do a specific treatement when I have any sort of exception that comes from apiB.

So i write :
methodA(){
try {
methodB();
} catch ( ExceptionB e){
throw new ExceptionA(e.getMessage())
}
}
But i have this problem of best paractices : Preserve Stack Trace : "Caught exception is rethrown, original stack trace may be lost"


Please help
Aditya Kanitkar
Ranch Hand

Joined: Aug 08, 2009
Posts: 72
Preserve Stack Trace : "Caught exception is rethrown, original stack trace may be lost"


Is this the error you are getting...??
I'm missing out something...
Samy Ganou
Greenhorn

Joined: Oct 05, 2009
Posts: 28
I don't have an error ,
This is a warning when i pass the project on sonar : SONAR is an open source quality management platform..
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Java Exception