How do you guys/girls trap Javascript errors in oncomplete and afterfinish? The browser nor FireBug reports JS errors that occur in this block. It just stops processing with no indication of where the error occurred. Currently I use a try/catch statement and print the error in the catch. Something like this: new Ajax.Updater(''div'', ''page.html'', { onComplete: function(t) { try { //some code } catch(err) { alert("There was an Error:\n" + err); } }); Are there better methods? Thanks --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
You can try the predefined events: onError, onException, onFailure -E On 12/14/06, JRigby <jeff.rigby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > How do you guys/girls trap Javascript errors in oncomplete and > afterfinish? The browser nor FireBug reports JS errors that occur in > this block. It just stops processing with no indication of where the > error occurred. > > Currently I use a try/catch statement and print the error in the catch. > Something like this: > > new Ajax.Updater(''div'', ''page.html'', { > onComplete: function(t) { > try { > //some code > } > catch(err) { > alert("There was an Error:\n" + err); > } > }); > > > Are there better methods? > > Thanks > > > > >-- Eric Ryan Harrison --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Specifically: 927 dispatchException: function(exception) { 928 (this.options.onException || Prototype.emptyFunction)(this, exception); 929 Ajax.Responders.dispatch(''onException'', this, exception); 930 } That block of code is excecuted if there is a code exception with any part of the Ajax request. This method is called throughout the Ajax object and is called at the first sign of trouble in any of the blocks. A simple usage example is as follows: new Ajax.Request(''index.html'',{ method: ''get'', onComplete: function(request,json) { alert(''request successful: '' + request.responseText); alert("I will cause a failure and onException should be called..." + some_var); }, onException: function(e) { alert("There was an error! Oh noes!\n" + e); } }); Enjoy. -E On 12/15/06, Eric Harrison <blister-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> You can try the predefined events: > > onError, onException, onFailure > > -E > > On 12/14/06, JRigby <jeff.rigby-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > > How do you guys/girls trap Javascript errors in oncomplete and > > afterfinish? The browser nor FireBug reports JS errors that occur in > > this block. It just stops processing with no indication of where the > > error occurred. > > > > Currently I use a try/catch statement and print the error in the catch. > > Something like this: > > > > new Ajax.Updater(''div'', ''page.html'', { > > onComplete: function(t) { > > try { > > //some code > > } > > catch(err) { > > alert("There was an Error:\n" + err); > > } > > }); > > > > > > Are there better methods? > > > > Thanks > > > > > > > > > > > > > -- > Eric Ryan Harrison >-- Eric Ryan Harrison --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Great! I don''t know how I missed this one. I knew about onFaliure but that only works for http errors. This will help a lot. Jeff --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---