Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iPad JavaScript Error not helpful

I get the following error and iPad but not in desktop browsers:

JavaScript: Error
undefined
TypeError: 'undefined' is not a function

This is a larger js application, and this error message is totally unhelpful. Is there any way I can get the line number of the error or anymore information?

Update: This just got funky.

line : 0    
page : undefined
desc : TypeError: 'undefined' is not a function
chr  : undefined

Did the user agent spoofing in FF and safari. No error.

like image 271
Fresheyeball Avatar asked Apr 17 '12 19:04

Fresheyeball


2 Answers

You could try registering a custom error handler to window.onerror

window.onerror = function (desc,page,line,chr)
{ alert('Line:'+line); }

desc = Error message
page = File/Page where the error occured
line = Well...
chr = Character position of the error in the line

like image 161
bardiir Avatar answered Oct 19 '22 00:10

bardiir


If you bind an error handler to window.onerror, it should give you the line number, e.g.

window.onerror = function(msg,url,line) {
   alert('The error is on line '+line);
}

This question: Debug JavaScript errors on iPad seems to indicate you can enable debugging too.

If the script is loaded dynamically, though, it can be hard to get such info in any environment.

like image 30
Jamie Treworgy Avatar answered Oct 18 '22 23:10

Jamie Treworgy