[Ovirt-devel] [PATCH server 2/3] * app/controllers/application.rb (handle_auth_error): pass in block

David Lutterkort lutter at redhat.com
Wed Apr 29 17:25:44 UTC 2009


On Wed, 2009-04-29 at 12:52 -0400, Scott Seago wrote:
> David Lutterkort wrote:
> > This makes dealing with auth errors a little more concise. Eventually, I
> > would like to change the signature of this method to be something like
> >
> >   handle_auth_error(exc_msgs={}, &block)
> >
> > so that we can pass in a mapping exception class => error message, i.e. a
> > typical call might be
> >
> >   handle_auth_error(
> >     ActiveRecord::RecordNotFound => "The object does not exist",
> >     ActiveRecord::StaleObjectError => "Midair collision, try again") do
> >     .. do stuff ..
> >   end
> >
> >   
> With something like the above, it seems like we've no longer got a 
> handle_auth_error method but a handle_application_error method, as it 
> would become a more general error-handling situation. Do you have any 
> examples from the current codebase where we're handling multiple 
> exception types that this would simplify? It seems like a good idea, I'm 
> just not sure concretely how it would be used.

There were a bunch json actions with an unconditional rescue clause,
presumably so that you get any indication that something went wrong.

After reading up on Rails error handling though, I think we should scrap
handle_auth_error entirely and use the rescue_from mechanism described
here[1]

David

[1] http://rails.learnhub.com/lesson/6381-action-controller-rescue





More information about the ovirt-devel mailing list