posted 17 years ago
Hi,
Really quick question. Within my URLyBird spec it says "Any methods that throw RecordNotFoundException should do so if a specified record does not exist or is marked as deleted in the database file. "
Therefore, within my readRec(long recNo) method, I check the validFlag field and if not equal to zero I throw a new RecordNotFoundException.
However, I have just completed the findByCriteria method, and I basically loop through each if the records. However, if any if the records I loop through are deleted I will get a "RecordNotFoundException" that will terminate my search across the file.
While coding, I put in the following
for loop that iterates through all rec
{
try
{
rec = readrec(index)
}
catch( RecordNotFoundException rnf )
{ continue; } //Check next record
for loop that iterates through all fields
{
}
}
My question is...Is the "continue" in the catch block bad programming practice? At the time, it was a hack, but the more I think about, I would prefer maybe to write another readRec that did not throw a RecordNotFound exception? But then duplicate code essentially.
It would be great to hear peoples opinions on this?
Thanks
Sophie