Hi, I''m using RoR as a web service to upload data. Unfortunately I''m often passed poorly formatted XML (it''s written by users, not by machine) and it often contains errors. The XML parser that tries to turn the XML into parameters barfs at some errors (e.g. mismatched opening and closing elements) and I cannot see how to trap this error and report something meaningful to the user. At the moment they get a stacktrace or an internal error message. Has anyone else come across this problem? How can I trap these errors for myself? Allan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
bump --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 1/31/08, Allan <Allan.Cochrane-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m using RoR as a web service to upload data. Unfortunately I''m often > passed poorly formatted XML (it''s written by users, not by machine) > and it often contains errors. > > The XML parser that tries to turn the XML into parameters barfs at > some errors (e.g. mismatched opening and closing elements) and I > cannot see how to trap this error and report something meaningful to > the user. At the moment they get a stacktrace or an internal error > message. > > Has anyone else come across this problem?Nah, you''re the first. :)> How can I trap these errors for myself?begin # process xml rescue raise "xml error: #{ $!.to_s }" # or whatever you need to do end -- Greg Donald http://destiney.com/ --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On Feb 1, 11:08 pm, "Greg Donald" <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 1/31/08, Allan <Allan.Cochr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > Has anyone else come across this problem? > > Nah, you''re the first. :):-)> > How can I trap these errors for myself? > > begin > # process xml > rescue > raise "xml error: #{ $!.to_s }" # or whatever you need to do > endAh, I still don''t quite get it. As far as see it, my controller is not handling the XML, the RoR framework is dealing with that for me, thereby populating the params hash and THEN my controller is invoked. My issue is that malformed XML is being presented to RoRand I cannot see how to trap the error. Are you suggesting a different mechanism? Allan --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Anyone? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
On 3 Feb 2008, at 21:38, Allan wrote:> > > > On Feb 1, 11:08 pm, "Greg Donald" <gdon...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> On 1/31/08, Allan <Allan.Cochr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >>> Has anyone else come across this problem? >> >> Nah, you''re the first. :) > > :-) > >>> How can I trap these errors for myself? >> >> begin >> # process xml >> rescue >> raise "xml error: #{ $!.to_s }" # or whatever you need to do >> end > > Ah, I still don''t quite get it. > > As far as see it, my controller is not handling the XML, the RoR > framework is dealing with that for me, thereby populating the params > hash and THEN my controller is invoked. My issue is that malformed > XML is being presented to RoRand I cannot see how to trap the error. > > Are you suggesting a different mechanism? >If all you want to do is display a friendly error message, then overriding rescue_action_in_public on that controller might be what you want to do. Or in 2.0 you can do class MyController < ApplicationController rescue_from SomeXmlException, :with => :bad_xml def bad_xml(exception) #render some useful message to the user end end> Allan > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---