Solved

Firebug debugging problems

Posted on 2011-02-11
5
730 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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 43

Accepted Solution

by:
Rob 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

Veeam gives away 10 full conference passes

Veeam is a VMworld 2017 US & Europe Platinum Sponsor. Enter the raffle to get the full conference pass. Pass includes the admission to all general and breakout sessions, VMware Hands-On Labs, Solutions Exchange, exclusive giveaways and the great VMworld Customer Appreciation Part

Question has a verified solution.

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

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
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 integrate Mailchimp with Facebook. This will be demonstrated using a Windows 8 PC. Mailchimp and Facebook will be used. Log into your Mailchimp account. : Click on your name. Go to Account Setti…
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

634 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