On 8/21/05, Jim Ray
<jim-rhf1kIDhBaeB8E1WFlbJj6xOck334EZe@public.gmane.org>
wrote:> Is there a specific reason why AR doesn''t raise a RecordNotFound
> exception in any exception other than "find(id)"? It would seem
> to be more consistent with the unified find if all types of
> find would raise a RecordNotFound exception.
>
>
>
> jim
> jim-rhf1kIDhBaeB8E1WFlbJj6xOck334EZe@public.gmane.org
>
>
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
I believe the reason for this is that when you are retrieving a record
based on a given id, you are doing so with the knowledge that a record
with that id exists. So, if no record is found, it''s an exceptional
circumstance, and RecordNotFound is raised for you to handle.
However, if you are retrieving records based on a set of conditions,
finding no records that match these conditions is a natural possible
outcome. In that case, there''s no reason for an exception to be
raised.
Gabe