[Ovirt-devel] [PATCH server 3/4] Remove handle_auth_error since we use rescue_with now

Scott Seago sseago at redhat.com
Tue May 5 00:26:18 UTC 2009


David Lutterkort wrote:
> ---
>  src/app/controllers/application.rb               |   27 +--------------------
>  src/app/controllers/storage_volume_controller.rb |    5 +++-
>  src/app/controllers/vm_controller.rb             |   12 ++-------
>  3 files changed, 9 insertions(+), 35 deletions(-)
>
> diff --git a/src/app/controllers/vm_controller.rb b/src/app/controllers/vm_controller.rb
> index ee6d79e..c276f0b 100644
> --- a/src/app/controllers/vm_controller.rb
> +++ b/src/app/controllers/vm_controller.rb
> @@ -65,8 +61,6 @@ class VmController < ApplicationController
>      begin
>        alert = svc_create(params[:vm], params[:start_now])
>        render :json => { :object => "vm", :success => true, :alert => alert  }
> -    rescue PermissionError => perm_error
> -      handle_auth_error(perm_error.message)
>      rescue Exception => error
>        json_error("vm", @vm, error)
>      end
>   

If I'm understanding the way rescue_from works (that the whole action 
method call in the controller is wrapped by a generated begin/rescue 
block based on the rescue_from construct) then the above won't work. The 
catch-all "rescue Exception" will also catch PermissionError since 
there's no longer a more specific rescue in this scope.  I think we'd 
need a rescue_from for the catch-all level as well.

Can rescue_from handle specific and more general errors at once? i.e. 
can we register a handler for Exception -- that will call an empty 
handle_general_error handler in application.rb -- which can be 
overridden where needed (such as here) to handle the case as above. 
Also, in the rescue_from handler is there any way to get at which action 
was called? This would allow us to have error-handling behavior that 
might be slightly different for specific actions.

Scott




More information about the ovirt-devel mailing list