Originally posted by Matt Sheehan.:
There is a built-in way to do this. Simply extend RuntimeException like this:
Then when you catch the DataAccessException you can use the inherited getCause() method to retrieve the original Exception.
SCJP 1.4<br />SCJD 1.4
Originally posted by Daniel Simpson:
Hey Matt, I'm not sure what assignment version you are using, but if I were to use the code example above, I would be violating an explicit must. My doc says that any exception created by us must have a default contstructor and another constructor that takes a string representing the error.
2. My defined exception:
2.a Server(DB) layer: DuplicateKeyException, RecordNotFoundException, DataAccessException, RecordHasModifiedException. These exception will be thrown at Data.class, and will be catch at logic layer.
Originally posted by Paula Decker:
Hello,
Leo wrote:
I have the B&S assignment, and I thought that the Data class could only throw DuplicateKeyException, RecordNotFoundException, and SecurityException. I don't think we can add a new exception, in your case: DataAccessException. I want to add a similar new exception, but do not know how to fit it in with the required design. Currently, my Data class, which accesses the file, is eating the IOException. I want to change this, by wrapping the IOException in a DatabaseException, but how can the new exception be thrown without violating the requirements?
Thanks for any input.
-Paula
![]()
MBA, PMP<br />SCJP, SCJD<br />ITIL Foundations Certified.
MBA, PMP<br />SCJP, SCJD<br />ITIL Foundations Certified.
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
“Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.” - Rich Cook
I have a DBLocalAdapter class that implements DBClient, and this is used as the local adapter. I also have a DBRemoteAdapter, which implements DBClient and Remote, and this is my remote adapter. The DBConnector class will return the appropriate DBClient object based on the flag.
I have the B&S assignment, and I thought that the Data class could only throw DuplicateKeyException, RecordNotFoundException, and SecurityException. I don't think we can add a new exception, in your case: DataAccessException. I want to add a similar new exception, but do not know how to fit it in with the required design. Currently, my Data class, which accesses the file, is eating the IOException. I want to change this, by wrapping the IOException in a DatabaseException, but how can the new exception be thrown without violating the requirements?
Thanks for any input.
Not looking good. I think this might be the end. Wait! Is that a tiny ad?
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
|