// Creates a new record in the database (possibly reusing a // deleted entry). Inserts the given data, and returns the record // number of the new record. public int create(String  data) throws DuplicateKeyException;
What is curious about this is that the data is supposed to be stored in a file. All the methods I have seen to write to a file will throw an IOException in certain error conditions. But according to this interface specification, the only exception I am permitted to throw is DuplicateKeyException. What am I supposed to do if the file system causes the write() method to throw an IOException? I want to return an accuarte error to the user, not DuplicateKeyException.
In the Data class, which implements this interface, I tried doing this:
but got an error because the interface that it is implementing only throws DuplicateException, not IOException.
I have similar problems with some of the other methods in this interface which produce IOExceptions.
Is it OK to change the interface to also throw IOException? And if not, how do you handle this type of error if it occurs? [ May 07, 2005: Message edited by: Lara McCarver ]
One possibility is that any new exceptions you want to throw from the class that implements DBMain is to extend them from RuntimeException. RuntimeExceptions do not need to be declared in the throws clause of a method.
As long as you state in your choices that you had to implement them as RuntimeExceptions due to the limitation of the DBMain interface you should be fine.