The new rescue_from in edge rails seems to conflict with ActionWebService, which I need for various other purposes. When I define, for example (with AWS gem installed): <b>rescue_from ActionController::RoutingError, :with => :page_not_found</b> I get the exception: <b>uninitialized constant ActionWebService::Dispatcher::ActionController::Base</b> OK, so AWS interfers with the inheritance chain I guess, but if I define: <b>rescue_from Object::ActionController::RoutingError, :with => :page_not_found</b> I get no errors, but then the rescue_from method isn''t invoked either. Anyone got any advice? I can get around this with rescue_action_in_public, but thats just not as nice. Cheers, --Kip --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Xavier Noria
2008-Apr-30 07:19 UTC
Re: rescue_from issue with AWS - uninitialized constant
On Apr 30, 2008, at 8:19 , Kip wrote:> The new rescue_from in edge railsrescue_from comes with Rails 2.> seems to conflict with > ActionWebService, which I need for various other purposes. When I > define, for example (with AWS gem installed): > > <b>rescue_from ActionController::RoutingError, :with > => :page_not_found</b> > > I get the exception: > > <b>uninitialized constant > ActionWebService::Dispatcher::ActionController::Base</b> > > OK, so AWS interfers with the inheritance chain I guess, but if I > define:The problem seems to be that ActionController::RoutingError is an unknown constant at the time that file is being interpreted. If that''s correct that''s unrelated to rescue_from, it just happens that Ruby sees a constant, tries to resolve it because it is an argument of a method it is calling (rescue_from), and fails. The first thing I''d try is to pass the exception class name instead of the exception class itself: rescue_from "ActionController::RoutingError", :with => :page_not_found If the exception gets raised it will be certainly already loaded and rescue_from will be able to find the match. -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Apr-30 07:56 UTC
Re: rescue_from issue with AWS - uninitialized constant
> > <b>uninitialized constant > > ActionWebService::Dispatcher::ActionController::Base</b> > > > OK, so AWS interfers with the inheritance chain I guess, but if I > > define: > > The problem seems to be that ActionController::RoutingError is an > unknown constant at the time that file is being interpreted. If that''s > correct that''s unrelated to rescue_from, it just happens that Ruby > sees a constant, tries to resolve it because it is an argument of a > method it is calling (rescue_from), and fails. > > The first thing I''d try is to pass the exception class name instead of > the exception class itself: > > rescue_from "ActionController::RoutingError", :with > => :page_not_foundI''ve seen ::ActionController::RoutingError work too I think. 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Xavier Noria
2008-Apr-30 08:35 UTC
Re: rescue_from issue with AWS - uninitialized constant
On Apr 30, 2008, at 9:56 , Frederick Cheung wrote:> I''ve seen ::ActionController::RoutingError work too I think.Good. For Kip: AWS defines a constant ActionController somewhere within its namespace. If putting a leading "::" works it would happen that rescue_from is invoked somehow within that namespace[*] and "ActionContoller" is found relative to something instead of as the top- level constant. The one in AWS does not have a child RoutingError constant, and since constant name resolution has no backtracking so to speak it fails at that point. -- fxn [*] Somehow means the way constant name resolution works. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Very helpful guys, thank you. The String argument to rescue_from works fine. Of course I made a stupid error for my example: ActionController::RoutingError is never going to be rescued in this way (since it relies on a normal controller execution). Therefore there is still a reason to use rescue_action(_in_public) in order to handle that error (unless I missed something entirely!) Cheers, --Kip On Apr 30, 6:35 pm, Xavier Noria <f...-xlncskNFVEJBDgjK7y7TUQ@public.gmane.org> wrote:> On Apr 30, 2008, at 9:56 , Frederick Cheung wrote: > > > I''ve seen ::ActionController::RoutingError work too I think. > > Good. > > For Kip: AWS defines a constant ActionController somewhere within its > namespace. If putting a leading "::" works it would happen that > rescue_from is invoked somehow within that namespace[*] and > "ActionContoller" is found relative to something instead of as the top- > level constant. The one in AWS does not have a child RoutingError > constant, and since constant name resolution has no backtracking so to > speak it fails at that point. > > -- fxn > > [*] Somehow means the way constant name resolution works.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Xavier Noria
2008-May-01 10:16 UTC
Re: rescue_from issue with AWS - uninitialized constant
On May 1, 2008, at 4:41 , Kip wrote:> Very helpful guys, thank you. The String argument to rescue_from > works fine. Of course I made a stupid error for my example: > ActionController::RoutingError is never going to be rescued in this > way (since it relies on a normal controller execution). > > Therefore there is still a reason to use rescue_action(_in_public) in > order to handle that error (unless I missed something entirely!)Why it follows? rescue_from is written in a way that does not assume the exceptions you declare will ever exist. That''s why it understands a string with an exception class name as well as an excection class. In its implementation if a string is unknown as constant by the time some exception is being processed it just ignores it and continues. That''s by design. -- fxn --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-May-01 10:29 UTC
Re: rescue_from issue with AWS - uninitialized constant
On 1 May 2008, at 11:16, Xavier Noria wrote:> > On May 1, 2008, at 4:41 , Kip wrote: > >> Very helpful guys, thank you. The String argument to rescue_from >> works fine. Of course I made a stupid error for my example: >> ActionController::RoutingError is never going to be rescued in this >> way (since it relies on a normal controller execution). >> >> Therefore there is still a reason to use rescue_action(_in_public) in >> order to handle that error (unless I missed something entirely!) > > Why it follows? > > rescue_from is written in a way that does not assume the exceptions > you declare will ever exist. That''s why it understands a string with > an exception class name as well as an excection class. >I think Kip''s point is that ActionController::RoutingError is thrown when a controller could not be found that matched the url, so having something in a controller to rescue_from it is futile. Fred> In its implementation if a string is unknown as constant by the time > some exception is being processed it just ignores it and continues. > That''s by design. > > -- fxn > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Xavier Noria
2008-May-01 10:38 UTC
Re: rescue_from issue with AWS - uninitialized constant
On May 1, 2008, at 12:29 , Frederick Cheung wrote:> > On 1 May 2008, at 11:16, Xavier Noria wrote: > >> >> On May 1, 2008, at 4:41 , Kip wrote: >> >>> Very helpful guys, thank you. The String argument to rescue_from >>> works fine. Of course I made a stupid error for my example: >>> ActionController::RoutingError is never going to be rescued in this >>> way (since it relies on a normal controller execution). >>> >>> Therefore there is still a reason to use rescue_action(_in_public) >>> in >>> order to handle that error (unless I missed something entirely!) >> >> Why it follows? >> >> rescue_from is written in a way that does not assume the exceptions >> you declare will ever exist. That''s why it understands a string with >> an exception class name as well as an excection class. >> > I think Kip''s point is that ActionController::RoutingError is thrown > when a controller could not be found that matched the url, so having > something in a controller to rescue_from it is futile.Oh yes. --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---