Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stop suppressing JavaScript errors

I'm using Firebug to view JavaScript errors. But I'm also using jQuery. For some reason, I never see JavaScript errors when using jQuery and this is one of the biggest problems with working with jQuery in the first place.

There's no particular code to show, just imagine alert(areareg); where areareg is undefined or any sort of JavaScript error, and Firebug won't tell me about it. The JavaScript will simply fail without warning or notification of any sort. This is always the case, in any project where I've used jQuery and it's the only reason I don't like jQuery; because it's notoriously difficult to debug when something goes wrong.

For some reason I've even had trouble finding this question raised online, let alone answered. But I figured I'd give it a try here:

  1. Is there any way to make jQuery stop suppressing error messages?
  2. Am I the only one in the world who has always had this problem with jQuery?

EDIT: I use both Firefox (with Firebug) and Chrome, and I only use the non-minified version of jQuery. Still, I have never in my entire life seen a jQuery error message of any kind, neither useful nor useless, nor in fact normal JavaScript errors, when using jQuery.

like image 216
Teekin Avatar asked Dec 12 '10 20:12

Teekin


People also ask

How to disable error message in JavaScript?

In the Errors tab: Check/clear the Enable JavaScript Error Capture checkbox to enable/disable JavaScript error display.

How to avoid runtime error in JavaScript?

JavaScript provides error-handling mechanism to catch runtime errors using try-catch-finally block, similar to other languages like Java or C#. try: wrap suspicious code that may throw an error in try block. catch: write code to do something in catch block when an error occurs.

Does JavaScript error stop execution?

If an error occurs, then the try execution is stopped, and control flows to the beginning of catch (err) .

How do I hide console errors?

console. clear(); is good option to hide the console error because some time on running site we don't want to show error so we hide them in PHP.


2 Answers

I use google Chrome for my debugging, and it's pretty good, it shows all the jquery errors as well (as Alfred said, if you use minified version, you wont get any meaningful name in your errors, so it's better to use the raw source)

like image 32
Sina Fathieh Avatar answered Sep 24 '22 17:09

Sina Fathieh


Well, despite your impression, jQuery itself doesn't do anything to "suppress" error messages. Now, Firefox does tend to throw away certain kinds of exceptions, notably like what you describe. I often find that wrapping a whole Javascript block in a try ... catch with an alert call should an exception happen is a useful way to deal with it, but it's still irritating.

like image 72
Pointy Avatar answered Sep 20 '22 17:09

Pointy