+2

No Error reporting? Firebug lite does not catch JS errors?

Tom Auger 10 years ago in General updated by Alexander Blach (Developer) 7 years ago 8
My biggest beef with most of the code editors out there is the lack of console logging and error reporting. Correct me if I'm wrong, somebody, but Firebug Lite just doesn't cut it when dealing with JS errors - you know, syntax errors, illegal tokens, undeclared variables, attempting to call a method on an undefined object (a pretty common error), etc.... All the javascript errors that Firebug or Chrome would normally catch on a desktop just aren't caught with FB Lite.

This app needs more robust, built-in error reporting beyond linking in an external library that is, itself, powered by Javascript and so presumably dies as soon as an actual JS error is thrown. What's the point of that? Coffeescript has a pretty robust error logger, and CodePad has a mediocre one, but at least they'll catch the errors in the following, whereas Textastic with Firebug Lite just does nothing at all. You're in good (bad) company: Koder and Kodiac both suffer from the same disease. See the error-ridden code below:

console.log("log");
alert("hey");
fffx(); // undefined function 
ggg.h() test $< // method on undefined function and then illegal tokens

Not to appear completely negative,the Navigator is epic, and your options for file interchange are best in class.

Just really surprised that you can't really use this app for JS development, since there's no way to report JavaScript errors. Am I mistaken?

Answer

Answer

Textastic 6.3 adds a new JavaScript console that can show errors in your JavaScript code and allows you to log custom messages using the JavaScript Console object (for example by calling the console.log() method).

How are you using Firebug Lite? In the preview window, you can enable Firebug, but that is really only useful for inspecting elements because it is loaded after the page is loaded and JavaScript is already executed.

Did you try to reference it directly from your HTML as the first script as described on the Firebug Lite site? http://getfirebug.com/firebuglite#Stable
Hi Alex, thanks for the quick response!

Yep, I am loading FBLite from CDN or local lib if it exists. And HTML debug=true. I load it before anything else in the HEAD. However, syntax errors in any js scripts referenced in that HTML doc still do not show any results in the FBLite console. Do you get different results when you try the same thing?
The problem, as you wrote is that FireBug itself is JavaScript-based, so it probably dies when there is an actual syntax error in other JavaScript code.

I'm not sure if iOS offers the means necessary to report JavaScript errors in a web view. iOS 7 might have brought something new in this area, but I'll have to look into it. 
The author of CodePad (Mojocat) has been quite responsive, and he has figured out a way to achieve js error reporting in iOS6. Might be worth exchanging knowledge... http://mojocatplay.com/contact/
IOS does indeed have some solutions as a quick Google search turned up. Looks like the easiest to implement is a proxy to your UIWebView which can intercept the error and gives you the opportunity to surface it to the end user.

Take a look at this SE answer: http://stackoverflow.com/a/193282/467386 There also seems to be a drop-in already created that will do this on github: https://github.com/PabloGS/UIWebView-Debug though it's 2 years old. On the plus side, that means it doesn't require iOS7, which is a good thing.
This uses private APIs (private method setScriptDebugDelegate), so I can't really use it.
I'm using Koder daily for basic javascript and html editing, and the inability to display errors is really annoying... Everytime I have an error I can't figure out myself, I have to move the file to my desktop computer just to read the error log.
I started to call firebug lite from my code to have console.log messages since the beginning, but I haven't found a solution for the error messages... Have you guys figured out a way since 1 year ago?

Answer

Textastic 6.3 adds a new JavaScript console that can show errors in your JavaScript code and allows you to log custom messages using the JavaScript Console object (for example by calling the console.log() method).