Have a quick question about the spec on RecordNotFoundException. It reads (B&S 2.3.2):
Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file.
The methods it refers to are: read, update, delete, find, lock, and unlock.
My question is, how flexible is this requirement? For example, I throw RecordNotFoundException in the following circumstances:
read Attempt to read a record marked deleted
*EOFException (if reading past end-of-file)
*IOException (generic)
update Attempt to update a record past the end of the file
Attempt to update a record marked deleted
*InvalidLockException (custom exception if thread doesn't own lock)
*IOException (generic)
delete *InvalidLockException (custom exception if thread doesn't own lock)
*IOException (generic)
find If no matching records are discovered at all
*IOException (generic)
lock does not get thrown unlock If a thread tries to unlock a record that is not locked
* These exceptions are wrapped inside a RecordNotFoundException and unwrapped further up the code.
Three questions:
1. Is wrapping exceptions into a RecordNotFoundException consistent with the spec?
2. My design doesn't call for lock()/unlock() to know anything about the underlying record structure. I really don't want my lock() method to have to verify that a given record is legitimate. That shouldn't be it's job. "You want a lock on record 9000? Fine, go ahead!" It's the
other methods' duty to know a record is invalid. But is this consistent with the spec?
3. Similar to #2, my delete does not throw an exception if the user tries to delete a row that has already been deleted, or if it tries to delete a row beyond the end of the file. It just gracefully returns. Is this out of harmony with the spec?
The word "must" is not used, so I'm wondering how strict we need to be in following these guidelines. (Naturally, I can always document it in my choices.txt, but I want to make sure it's not an "automatic" failure or deduction of points).
Any thoughts?
[ March 28, 2008: Message edited by: Ryan Kade ]