Solved

Firebug debugging problems

Posted on 2011-02-11
5
664 Views
Last Modified: 2012-05-11
I'm using Firebug for debugging Javascript in Firefox.  It works well in many ways, but there are a few things I can't get to work.  They both relate to exceptions.

When the script causes an exception, Firebug shows an error message in the console and stops.  However, there is no stack trace and nothing in the watch panel.  The exception happens in a function that is called from many other functions.

I've tried setting Break On All Errors, it makes no difference.  I've set the Show Stack Trace With Errors option, still no difference.  I could use the error message in the console to set a breakpoint on the line that causes the exception, only this stops every time the function is called.  Which means I can't run the script long enough to generate the exception.

This leads to the second problem.  Once I've set a breakpoint from the console, execution always stops at that line but the breakpoint dosen't show in the script view.  I can't find a way to remove it.
0
Comment
Question by:satsumo
  • 2
  • 2
5 Comments
 
LVL 18

Expert Comment

by:Sudaraka Wijesinghe
Comment Utility
Availability of the stack trace depends on how the exception is generated. For internal JS exception trace is generated almost all the time. But for custom exceptions, you have to throw and Error object in order to get the trace.
throw 'custom error message'; //No stack trace generated

throw new Error('custom error message'); //Stack trace is generated

Open in new window


For your second question, all available break points are listed on the script tab on the right hand side "Breakpoints" panel.
0
 
LVL 12

Author Comment

by:satsumo
Comment Utility
The line that causes the error is using a 2D context on a Canvas.  It's calling context.drawImage() and supplying negative coordinates for the source, which causes the exception.  I have solved the original bug now, but it has appeared before and is likely to turn up again.  Does the canvas count as a custom exception? Surely it's part of the browser.  I can't see how I can throw an error except unless I wrap any calls to the context in a try-catch structure?

Thanks for answer to the removing the breakpoint part.  It seems obvious now that you've pointed it out.
0
 
LVL 18

Expert Comment

by:Sudaraka Wijesinghe
Comment Utility
I'm not familiar with the 2D canvas thing you mentioned, but if it's a 3rd party library, it's possible it's just throwing out text as the exception.

Only way to deal with exceptions gracefully is to catch them in try-catch blocks. However you can throw one from anywhere.
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 500 total points
Comment Utility
2D context is HTML5 specific so it is possible that the javascript isn't fully developed / implemented.  In fact I haven't been able to find a comprehensive spec for the Canvas tag and it's associated javascript.

Specification
A link to a formal specification of the context type's API. It could be another page on the Wiki, or a link to an external page. If the type does not have a formal specification, an informal description can be substituted until such time as a formal specification is available.

you could try using the onerror event of the canvas tag and see if it captures anything
0
 
LVL 12

Author Closing Comment

by:satsumo
Comment Utility
Thanks for the answers.  I guess you're right, Firefox dosen't have proper support for Canvas errors yet.  I've switched to Chrome, which catches the errors perfectly.
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
The purpose of this video is to demonstrate how to Import and export files in WordPress. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp-login.php : Click on Too…
The purpose of this video is to demonstrate how to prevent comment spam on a WordPress Website. This will be demonstrated using a Windows 8 PC. Plugin Akismet will be used. Go to your WordPress login page. This will look like the following: myw…

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now