When using ActiveRecord finders that don't by throw a RecordNotFound exception I'm finding myself writing code like the following:
@tag = Tag.find_by_name(params[:id]) or raise ActiveRecord::RecordNotFound
I don't really like the idea of raising a RecordNotFound myself, as, at the least, I don't get the exception message that ActiveRecord includes if it throws the exception internally ("Couldn't find Tag with ID=9999")... and it just feels... wrong.
Wouldn't it be better to have a finder option to specify you want an exception thrown if there's no record found?
@tag = Tag.find_by_name(params[:id], :throw_not_found => true)
Other possible APIs:
:throw_if_not_found => true
:throw_if_nil => true
:throw_when_not_found => true
:throw_when_nil => true
:throw_on_not_found => true
:throw_on_nil => true
:not_found => :throw
-- tim lucas