How do you handle a record not found?

Just out of curiosity, how do you handle a database record not found?

Throw an exception or some other predictable value?

2 Comments

  • this is a classic ...



    "it Depends" :-)

  • Denny's right, it depends. Usually the data access layer throws an exception (since using "magic" values is not a good thing to do) and the UI catches it and shows an error message. So I guess I would go with throwing an exception - unless not having a record is a normal operation, such as returning a list of search results, as oposed to returning a record to edit.

Comments have been disabled for this content.