aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Back again, About Exception Question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Back again, About Exception Question" Watch "Back again, About Exception Question" New topic
Author

Back again, About Exception Question

Jesse Xie Y.S.
Greenhorn

Joined: Feb 09, 2004
Posts: 20
I prefer to implement a business logic layer between user client and database, and I am just confusing about how could I deal with so much exception. Should I ignore the IOException? Could I ignore the RemoteException? Or maybe I could just transform it into other exception such as RecordNotFoundException or RoomNotFoundException?

Any help. TKS very much.


MOON -- SCJP1.2
Thomas Paul Bigbee
Ranch Hand

Joined: Jun 28, 2005
Posts: 71
http://java.sun.com/j2se/1.4.2/docs/guide/lang/chained-exceptions.html

The link above will take you to a good article on how to chain exceptions.

You can't ingnore Checked Exceptions, and you can't specify any new/broader exceptions when implementing an interface, you can however,chain exceptions (throw a RuntimeException) from within the IOException catch block, with the Cause and Stack information from the original exception, and handle it in the business tier

Hope this helps
Tom
Jesse Xie Y.S.
Greenhorn

Joined: Feb 09, 2004
Posts: 20
Hi, good day every one. I really don't know how to deal with IOException.

public synchronized long[] findByCriteria(String[] criteria) {
long[] result;
try{
dataFile.seek(getLocation(recNo));
... ...
return result;
} catch (IOException ioe) {
ioe.printStackTrace();
//If have exception return null;
return null;
}
//If have no result,return 0 length array
return new long[0];
}

how do you think?
Jesse Xie Y.S.
Greenhorn

Joined: Feb 09, 2004
Posts: 20
Hi Thomas, after I read over this forum about the IOException, I found that it is really a big problem. and now, I want to try your suggestion.

So I just create a new DataException and extends from RuntimeException, and I will catch it on business layer.

I think it's normally a fetal error about reading file, because my program will make sure that the file exist before create new Data instance.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Back again, About Exception Question