An important announcement from the founder of property-bee.com: The future of Property Bee is assured.

Bug #161: If there is a syntax error in the code, no useful

An area to discuss the development and technical aspects of the toolbar

Bug #161: If there is a syntax error in the code, no useful

Postby Beerhunter on Sat Oct 31, 2009 8:28 pm

I'm being thrawted by xcopy running out of memory failing to copy 300GB of data, so whilst I try robocopy....

I'm looking at how to improve the error messages during development when there's a syntax error in the source code.

Currently there are 'random' (ie I just kept on adding them until things worked) includes, thats code like

Code: Select all
// bit like #include 'xxx.js' in C/C++
Components.classes['@mozilla.org/moz/jssubscript-loader;1'].getService(Components.interfaces.mozIJSSubScriptLoader).loadSubScript('chrome://property-bee/content/xxx.js');


What I didn't realise at the time is that this line of code throws an exception if file xxx.js has a typo in! So if you have file A includes file B, which includes file C ... if there is a typo in file C that stops files B and A being loaded too :shock:

So the solution is to wrap each include in a try block, and report any exceptions thrown.


To make things a bit more manageable, I've also looked at the dependencies between files, and come up with a neat/simple solution;

* The toolbar / sidebar includes just the new source file pb.js; eg in pb_sidebar.xul;

Code: Select all
<script type="application/x-javascript" src="chrome://property-bee/content/pb.js" />


* When the toolbar / sidebar windows initialise, before the do anything, they call the function 'PB.initialise()' which is in pb.js

Code: Select all
PB.initialise(); // Load the rest of the source code, including th fn pb_initSidebar()
window.addEventListener("load", pb_initSidebar, false); // When the sidebar xul is loaded, create the code to drive it


* PB.initialise() loads all the other source files; "pb_db.js", "pb_request.js", ...., "pb_wizard_upgrade.js" and will pop up a dialog if any of these files have a syntax error :D


I've just committed the change, so hopefully make development/bug fixing quicker when tracking down typos!


If you want to test it out; just add a syntax error in any js file (apart from components/pb_service.js and components/pb_testharness.js - it won't work in these :(), and startup firefox, you should bet a much better error message and a filename / line number where the error is :D
User avatar
Beerhunter
Site Admin
 
Posts: 1788
Joined: Tue Jan 22, 2008 12:05 am

Re: Bug #161: If there is a syntax error in the code, no useful

Postby Beerhunter on Sat Oct 31, 2009 8:55 pm

I should add this currently breaks the unit test framework, tho intend to look at this early next week.
User avatar
Beerhunter
Site Admin
 
Posts: 1788
Joined: Tue Jan 22, 2008 12:05 am


Return to Development

Who is online

Users browsing this forum: No registered users and 7 guests

cron