On 8 Oct 2008, at 03:18, Tim Uckun wrote:

>
> I am utterly unable to control how exceptions are handled in my
> application and it's driving me nuts
>
> The idea is simple. I have  a SOAP handler like this.
>
> class RtiController < ApplicationController
>
>  begin
>     wsdl_service_name 'Rti'
>     web_service_scaffold :invoke
>     web_service_api RtiApi
>
>     before_invocation :authenticate
>
>     include SoapMethods
>
>     protected
>
>     def authenticate (name, args)
>        #the first two arguments are always username and password
>        generic_login(args[0], args[1])
>        unless logged_in?
>           raise  Exceptions::LoginFailedError , "LoginFailedError:
> Invalid user name or password"
>        end
>     end
>
>  rescue Exception => e
>     n = e.exception "#{e.inspect}: #{e.message}"
>     n.set_backtrace []
>     raise n
>  end
> end
>
> Simple right?
>
> If any error gets raised either in the authenticate function or any of
> the functions in the included module I want to catch them and re-raise
> a new error.
>
> The rescue block never gets called no matter where the error happens.
>
That rescue block doesn't do what you think. The way you need to think  
about it is after the interpreter hits that begin, what code does it  
execute before it hits the rescue clause?
It does not for example execute the authenticate method. It does  
however call the web_service_api method, so if that raised an  
exception then it would catch it


> Next I try this.
>
> def rescue_action
> do the same thing above
> end
>
> Nope it never gets called either.
>
> So I try this
>
> rescue_from  Exception do |e|
>        n = e.exception "#{e.inspect}: #{e.message}"
>       n.set_backtrace []
>       raise n
> end
>
> I also tried rescue_from SomeSpecificException  and that doesn't  
> work either.
>
> I also tried putting a begin rescue block in the included module and
> that doesn't do anything either.
>
> Why is this so complicated? I just want a  error handler for
> this controller.  Is actionwebservice messing with the controller or
> what?
>
If you look at the actionwebservice code it is rescuing exceptions  
before you get to them (see dispatch_web_service_request in 
http://github.com/datanoise/actionwebservice/tree/master/lib/action_web_service/dispatcher/action_controller_dispatcher.rb)

Fred
> P.S. I am using the datanoise actionwebservice.
>
> >


--~--~---------~--~----~------------~-------~--~----~
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]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to