Solved

Firebug debugging problems

Posted on 2011-02-11
5
693 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
ID: 34878961
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
ID: 34879337
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
ID: 34881573
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
ID: 34894439
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
ID: 35006210
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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Because your company can’t afford for you to make SEO mistakes, you’ll want to ensure you’re taking the right steps each and every time you post a new piece of content. This list of optimization do’s and don’ts can help you become an SEO wizard.
Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
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…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

813 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

15 Experts available now in Live!

Get 1:1 Help Now