Verbose Error reporting in iPhone Safari? - javascript

So we have a large JS web-app running on our server, whose majority audience are running it off mobile browsers - mostly Safari on Iphones. JS errors are caught using Airbrake Error Catcher. However, investigating live bugs that appear via Airbrake is frustrating due to Safari truncating its error messages. What outputs as this on desktop browsers:
TypeError: 'undefined' is not an object (evaluating 'blah.currency_symbol')
appears as below on Safari iPhone:
'undefined' is not an object
So unless I know how or where to reproduce the error, I've no way of knowing what's going wrong & where.
Long story short - is there anyway of capturing more verbose error information from Safari iPhone? I tested using try/catch but the object still only returned the truncated message.
(apologies if this has been asked before, no searches seemed to yield answers)

Hmmm, no responses but I think from my own further tests the answer might be an insurmountable 'no' - I did the simplest test I could think of, binding to the error object and capturing the error response in the callback. It seems that the truncated error (e.message) is the main form of the response iOS Safari uses, and even other standard values in the object - such as filename or linenumber - aren't being set at all. Seems like before the object is even passed back to the console Safari truncates it 'helpfully' :(

Related

TypeError: Cannot read property 'pause' of underfined - happens only sometimes

I know what this error means in general. If I had 'pause' (or 'play') variables in my code not set by the time of execution, I would probably get this error. The strange thing is I have no clue where those variables come from. I am getting this error only on one PC (other 2 PCs I've tested seem completely OK) and the errors block the rest of my code.
At first it seemed to me some Chrome extension is causing the error, but I am getting the same error on Edge as well. Sometimes it works (even on the mentioned problematic PC).
What could be the issue?

What could cause console.log to not support method 'log'

All of a sudden, I am getting the following error when IE11 (not FF or Chrome) encounters console.log(ayb);. There is too much other JavaScript on the page, and I am only asking for hypothetical causes or a strategy to troubleshoot. When using console.log(ayb); without any other JavaScript on the page, it works as expected.
Object doesn't support property or method 'log'

Javascript IDE that can tell me where the crash occured & let me inspect variable values at that point

Can anyone suggest a Javascript IDE that will help me with debugging, for example be able to tell me which .js file & which function/line caused a crash?
I am currently using Notepad2 & its extremely difficult if not impossible to figure out why the app is crashing. Right now if I attempt to print out the object/variable causing the crash using...
alert(obj);
...It causes a crash. It is really frustrating because something weird is happening where just accessing the variable - ie passing the variable in a function as a parameter or alerting it - causes Firefox to have a catastrophic crash & Safari just has no failure output(I'm sure the error occurs but it recovers gracefully).
Ever experienced this kind of problem with Javascript before? Maybe you can say "I know what that is because its happened to me before, its x doing y"?
For example: "I know what that is because its happened to me before, your calling a prototype/object static function as a member function"
Internet explorer have Console ( in IE 8 and IE 9 console is usable ) - press F12
Firefox have plugin named firebug
Chrome and Opera have built in consoles ( Press Ctrl + Shift + I )
All of them know what it is break point, can watch some variables etc.
Chrome speciality is break on event.
IE speciality is break on error, and recover from error.
All of them allows you to find out place where script crashes
Most modern browsers come with a Javascript debugger. Safari/Chrome have the Script area in the Webkit Inspector. It allows you to set breakpoints, step through code and inspect variable states. Firefox has something similar in Firebug.

Javascript + Firebug console.log(), how to not get exceptions?

I'm writing a javascript / HTML5 canvas library to provide basic GUI elements for web audio applications.
There's a little demo script that creates widgets with the library and assemble them in a GUI. You can find it # http://bitterspring.net/webshifter/
The problem is, it seems to work correctly on Chrome and on Firefox 3.6 - 4.0 but, in the last cases, only with firebug. Without firebug, the script seems to visualize nothing on screen, while with firebug it does.
The only firebug-related pieces of code are some console.log statement I use to track the behaviour of the library. But these statements should have no effect on a non-firebug enabled browser, as I learnt from Firebug forums. What can prevent the example script to work, in these cases?
The library + example code is freshly committed on http://github.com/janesconference/KievII , by the way.
EDIT: Seems that, when console is not defined, console.log() throws an exception. Is there a way to keep the logging lines of code and not getting the exception? (yeah, one could check if console != undefined, but is there a better way?)
EDIT: This does the trick, it seems (Font)
if (typeof console=="undefined"){console={log:function(A){var B=false;if(B){alert(A)}}}}
Right, the console object is not available in all browsers by default.
This code:
if (typeof console=="undefined"){console={log:function(A){var B=false;if(B){alert(A)}}}}
- currently disables console support in Firefox 4's Web Console, since it tries to inject the console object when opened and won't do that if the page already defined a console object.
An interesting wrapper for console that deals with this problem is: http://benalman.com/projects/javascript-debug-console-log/ , although I haven't tried it myself.

Finding Parse Errors in Javascript

Is there an easy way to find parse errors in javascript code?
Last week I was debugging a javascript problem where the first javascript function that was called gave an 'object expected' error. I later determined that this was because the browser wasn't able to parse my javascript code. I eventually solved the problem but it was a painful process that involved pouring over my code line by line, trying to find my mistake.
There must be an easier way.
Use a tool like Jslint or an alternative browser.
Until recently, IE was the only browser that did not have built in development assistance. Other browsers will a) not come to a grinding halt on the first error they encounter, and b) tell you what and where the problem in your code is.
My favorite "quick ad easy" way to test IE syntax problems is to load the page up in Opera. It parses code like IE but will give you meaningful error messages.
I'll clarify with an example:
var foo = {
prop1 : 'value',
prop2 : 'value',
prop2 : 'value', // <-- the problem
};
If I remember correctly: In IE6 and IE7 the code will break because IE demands leaving the last comma out. The parser throws a fit and the browser simply stops. It may alert some errors but the line numbers (or even filenames) will not be reliable. Firefox and Safari, however, simply ignore the comma. Opera runs the code, but will print an error on the console indicating line number (and more).
Easiest way to write JavaScript is with Firefox + Firebug. Test with IE and have Opera tell you what is breaking when it does.
What browser are you using? IE8 has great build-in feature to debug javascript, for Firefox, Firebug is great.
Checking that the values passed into functions are correct and throwing your own errors if they aren't will help you track down problems faster.
Safari 4 (which runs on both Mac OS X and Windows) comes with some development tools (including a debugger) that are very useful. If you prefer using Firefox, Firebug provides similar functionality.
JSLint can help you track down simple errors.
Steve

Categories

Resources