On Sunday, September 16, 2012 7:57:44 PM UTC+1, John Merlino wrote:
>
>   class ActionNotFound < StandardError #:nodoc: 
>   end 
>
> unless action_name = method_for_action(action_name) 
>   raise ActionNotFound, "The action '#{action}' could not be found for 
> #{self.class.name}" 
> end 
>
> But why even bother to create the subclasses (which as shown above, 
> have no definition of themselves), when substituting ActionNotFound 
> with StandardError during the raise call will have the same effect. 
>

Because it doesn't have the same effect. Raising specific subclasses allows 
you to write targeted rescue clauses rather than rescuing indiscriminately.

Fred 

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msg/rubyonrails-talk/-/IQOCofRA-TEJ.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to