Solved

Firebug debugging problems

Posted on 2011-02-11
5
681 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
This guide will walk you through the essential considerations and tech stack for building scalable websites. Know how to grow your business the smart way!
The purpose of this video is to demonstrate how to set up an RSS Feed on a WordPress Website. This will be demonstrated using a Windows 8 PC. Feedburner will be used for this demonstration. Go to your WordPress login page. This will look like the…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

895 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

19 Experts available now in Live!

Get 1:1 Help Now