<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: The Art of Throwing Errors in JavaScript</title>
	<atom:link href="http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/feed" rel="self" type="application/rss+xml" />
	<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript</link>
	<description>Cleaning up the web with Ajax</description>
	<lastBuildDate>Thu, 09 Feb 2012 06:55:33 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2</generator>
	<item>
		<title>By: BertrandLeRoy</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271831</link>
		<dc:creator>BertrandLeRoy</dc:creator>
		<pubDate>Fri, 06 Mar 2009 05:22:50 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271831</guid>
		<description>@braddunbar: no problem. I apologize myself for being a little rude.</description>
		<content:encoded><![CDATA[<p>@braddunbar: no problem. I apologize myself for being a little rude.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: braddunbar</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271829</link>
		<dc:creator>braddunbar</dc:creator>
		<pubDate>Fri, 06 Mar 2009 02:06:22 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271829</guid>
		<description>@BertrandLeRoy I did not know that the error checking was taken out of the production version.  Thanks for pointing that out, and my apologies for any misrepresentation I gave.</description>
		<content:encoded><![CDATA[<p>@BertrandLeRoy I did not know that the error checking was taken out of the production version.  Thanks for pointing that out, and my apologies for any misrepresentation I gave.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: BertrandLeRoy</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271827</link>
		<dc:creator>BertrandLeRoy</dc:creator>
		<pubDate>Thu, 05 Mar 2009 23:15:02 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271827</guid>
		<description>@braddunbar: please check before you make such uninformed statements. Microsoft Ajax, like most JavaScript libraries, comes in two flavors: minimized/release and debug. The error checking code is very extensive but is only present in the debug version, as it should. The release/minimized version has no error checking except on errors that might make sense for the end user and that are not developer errors (network timeouts and such).
As Microsoft Ajax has shown since the first version, it is entirely possible to provide meaningful error messages and stack traces to application developers without compromising performance, by only instrumenting the debug version.</description>
		<content:encoded><![CDATA[<p>@braddunbar: please check before you make such uninformed statements. Microsoft Ajax, like most JavaScript libraries, comes in two flavors: minimized/release and debug. The error checking code is very extensive but is only present in the debug version, as it should. The release/minimized version has no error checking except on errors that might make sense for the end user and that are not developer errors (network timeouts and such).<br />
As Microsoft Ajax has shown since the first version, it is entirely possible to provide meaningful error messages and stack traces to application developers without compromising performance, by only instrumenting the debug version.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: shadedecho</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271826</link>
		<dc:creator>shadedecho</dc:creator>
		<pubDate>Thu, 05 Mar 2009 22:42:40 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271826</guid>
		<description>I think at least some JS widgets/modules/libraries could benefit from explicit &quot;error callback&quot; functionalities, where the user of a library can explicity subscribe to know about certain internal (non-api-abuse related) and unforseeable events. For instance, I have an XHR clone library (called flXHR http://flxhr.flensed.com/ ) which exposes an &quot;onerror&quot; callback handler which will send all errors to that callback if defined. Otherwise, it throws them as javascript errors. I think this is the best of both worlds. And it&#039;s really not that much extra code to do so.</description>
		<content:encoded><![CDATA[<p>I think at least some JS widgets/modules/libraries could benefit from explicit &#8220;error callback&#8221; functionalities, where the user of a library can explicity subscribe to know about certain internal (non-api-abuse related) and unforseeable events. For instance, I have an XHR clone library (called flXHR <a href="http://flxhr.flensed.com/" rel="nofollow">http://flxhr.flensed.com/</a> ) which exposes an &#8220;onerror&#8221; callback handler which will send all errors to that callback if defined. Otherwise, it throws them as javascript errors. I think this is the best of both worlds. And it&#8217;s really not that much extra code to do so.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzammetti</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271825</link>
		<dc:creator>fzammetti</dc:creator>
		<pubDate>Thu, 05 Mar 2009 21:52:11 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271825</guid>
		<description>I agree with kumar303 here, and I&#039;d go a step further and say a good API should intentionally minimize the number of times you need to consult documentation.  With a good API, I can give you a simple list of method signatures, including exceptions that can be thrown, and that will largely be all the documentation you usually need.  The method names reflect their function, the argument names reflect what they are and the exception information tells you what can typically go wrong (it&#039;s all a little trickier in JavaScript of course, as dynamic as it is, but still).</description>
		<content:encoded><![CDATA[<p>I agree with kumar303 here, and I&#8217;d go a step further and say a good API should intentionally minimize the number of times you need to consult documentation.  With a good API, I can give you a simple list of method signatures, including exceptions that can be thrown, and that will largely be all the documentation you usually need.  The method names reflect their function, the argument names reflect what they are and the exception information tells you what can typically go wrong (it&#8217;s all a little trickier in JavaScript of course, as dynamic as it is, but still).</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Spocke</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271824</link>
		<dc:creator>Spocke</dc:creator>
		<pubDate>Thu, 05 Mar 2009 21:36:36 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271824</guid>
		<description>The main reason why I don&#039;t use exceptions in JS is the code size. Adding thousands of throws takes lots of space. But I guess one could have two versions of their scripts one with error checking enabled that could be used while developing then another production version that doesn&#039;t do all the error checking.

One could use a JS preprocessor to remove that error checking logic. I&#039;ve blogged about such a thing a few days ago. http://blog.moxiecode.com/2009/03/02/javascript-build-process-using-ant/</description>
		<content:encoded><![CDATA[<p>The main reason why I don&#8217;t use exceptions in JS is the code size. Adding thousands of throws takes lots of space. But I guess one could have two versions of their scripts one with error checking enabled that could be used while developing then another production version that doesn&#8217;t do all the error checking.</p>
<p>One could use a JS preprocessor to remove that error checking logic. I&#8217;ve blogged about such a thing a few days ago. <a href="http://blog.moxiecode.com/2009/03/02/javascript-build-process-using-ant/" rel="nofollow">http://blog.moxiecode.com/2009/03/02/javascript-build-process-using-ant/</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kumar303</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271823</link>
		<dc:creator>kumar303</dc:creator>
		<pubDate>Thu, 05 Mar 2009 21:28:02 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271823</guid>
		<description>&quot;null has no attribute named render&quot;

Do I need to say anything more?  Yes, throwing exceptions is the only way to ensure proper inputs.  People shouldn&#039;t have to always read documentation to figure out how something works.  I don&#039;t see how it introduces huge performance penalties as long as you design your functions right.</description>
		<content:encoded><![CDATA[<p>&#8220;null has no attribute named render&#8221;</p>
<p>Do I need to say anything more?  Yes, throwing exceptions is the only way to ensure proper inputs.  People shouldn&#8217;t have to always read documentation to figure out how something works.  I don&#8217;t see how it introduces huge performance penalties as long as you design your functions right.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nosredna</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271822</link>
		<dc:creator>Nosredna</dc:creator>
		<pubDate>Thu, 05 Mar 2009 20:38:13 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271822</guid>
		<description>fzammetti,

Anything calculation bound, I&#039;ve NEVER seen IE6 do well on. But I&#039;m willing to believe that there are real world problems where it does happen. There are many potential bottlenecks in the world of browsers. Everyone seems to be doing something a bit different. Just look at the wars between benchmarks.</description>
		<content:encoded><![CDATA[<p>fzammetti,</p>
<p>Anything calculation bound, I&#8217;ve NEVER seen IE6 do well on. But I&#8217;m willing to believe that there are real world problems where it does happen. There are many potential bottlenecks in the world of browsers. Everyone seems to be doing something a bit different. Just look at the wars between benchmarks.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzammetti</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271821</link>
		<dc:creator>fzammetti</dc:creator>
		<pubDate>Thu, 05 Mar 2009 20:25:33 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271821</guid>
		<description>@Nosredna: HAHA, I like that!
-
Ironically, and I&#039;ve said this on numerous occasions: I&#039;ve actually seen BETTER performance in many cases with IE6 than IE7, FF3 or Opera9 (I don&#039;t use Chrome, or Safari so can&#039;t really compare them).  Don&#039;t get me wrong: I have *NO* trouble believing that is due to factors other than the browser itself, i.e., configuration, network, whatever, but I&#039;ve seen it time and again in direct contradiction to what most of the &quot;experts&quot; always claim.
-
Still, great line :)</description>
		<content:encoded><![CDATA[<p>@Nosredna: HAHA, I like that!<br />
-<br />
Ironically, and I&#8217;ve said this on numerous occasions: I&#8217;ve actually seen BETTER performance in many cases with IE6 than IE7, FF3 or Opera9 (I don&#8217;t use Chrome, or Safari so can&#8217;t really compare them).  Don&#8217;t get me wrong: I have *NO* trouble believing that is due to factors other than the browser itself, i.e., configuration, network, whatever, but I&#8217;ve seen it time and again in direct contradiction to what most of the &#8220;experts&#8221; always claim.<br />
-<br />
Still, great line :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nosredna</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271820</link>
		<dc:creator>Nosredna</dc:creator>
		<pubDate>Thu, 05 Mar 2009 19:54:12 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271820</guid>
		<description>@fzammetti,

The speed improvements to JavaScript are great. It&#039;s just that our grandmother is in the room (IE6), and she keeps interrupting the conversation by saying, &quot;what, what, what?&quot;</description>
		<content:encoded><![CDATA[<p>@fzammetti,</p>
<p>The speed improvements to JavaScript are great. It&#8217;s just that our grandmother is in the room (IE6), and she keeps interrupting the conversation by saying, &#8220;what, what, what?&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: fzammetti</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271818</link>
		<dc:creator>fzammetti</dc:creator>
		<pubDate>Thu, 05 Mar 2009 19:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271818</guid>
		<description>Performance is of course a valid consideration here.  But, for those of us that have been doing Java development for a long time you can recognize that we&#039;re at a stage with JavaScript where we were with Java a few years ago: there&#039;s some really good ideas that you shy away from on the grounds of performance.  I think this is one of them.
-
For example, it used to be common knowledge that you should using StringBuffer in Java as opposed to simple string concats.  With modern VMs though, this isn&#039;t much of a consideration because they optimize that sort of thing behind the scenes anyway.  In light of that, code readability becomes the bigger concern (putting aside the debate about whether string concats actually are more readable or not!)
-
Similarly, we&#039;re starting to get super-fast JS engines and so at some point we have to start thinking more about readability and maintainability of code than performance, at least in some instances (you should *never* simply forget performance of course, just that sometimes it&#039;s OK to put it on the back burner in favor of other considerations).  It&#039;s of course valid to debate whether this throwing errors idea is good or not in the first place, but if you think it is as I do then at some point the consideration of writing &quot;better&quot; code takes precedence over performance.</description>
		<content:encoded><![CDATA[<p>Performance is of course a valid consideration here.  But, for those of us that have been doing Java development for a long time you can recognize that we&#8217;re at a stage with JavaScript where we were with Java a few years ago: there&#8217;s some really good ideas that you shy away from on the grounds of performance.  I think this is one of them.<br />
-<br />
For example, it used to be common knowledge that you should using StringBuffer in Java as opposed to simple string concats.  With modern VMs though, this isn&#8217;t much of a consideration because they optimize that sort of thing behind the scenes anyway.  In light of that, code readability becomes the bigger concern (putting aside the debate about whether string concats actually are more readable or not!)<br />
-<br />
Similarly, we&#8217;re starting to get super-fast JS engines and so at some point we have to start thinking more about readability and maintainability of code than performance, at least in some instances (you should *never* simply forget performance of course, just that sometimes it&#8217;s OK to put it on the back burner in favor of other considerations).  It&#8217;s of course valid to debate whether this throwing errors idea is good or not in the first place, but if you think it is as I do then at some point the consideration of writing &#8220;better&#8221; code takes precedence over performance.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: CaptainN</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271813</link>
		<dc:creator>CaptainN</dc:creator>
		<pubDate>Thu, 05 Mar 2009 16:42:55 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271813</guid>
		<description>I&#039;ve gone back and forth on whether to do this kind of error checking in SwfHTML (http://code.google.com/p/unfocus-history-keeper/source/browse/trunk/javascript/SwfHTML.js ). I&#039;ve become pretty comfortable in this instance. The errors have saved me a bit of work a number of times, by tracing an incorrect setting to Firebug, where if I hadn&#039;t used error checking I would have let those settings fail silently. In this example though, there are not a lot of performance issues, since this is a pretty basic object in scope - but still, I do find throwing errors to be a tremendous time saver, especially when you have to utilize some library or bit of code that you haven&#039;t used in a while.</description>
		<content:encoded><![CDATA[<p>I&#8217;ve gone back and forth on whether to do this kind of error checking in SwfHTML (<a href="http://code.google.com/p/unfocus-history-keeper/source/browse/trunk/javascript/SwfHTML.js" rel="nofollow">http://code.google.com/p/unfocus-history-keeper/source/browse/trunk/javascript/SwfHTML.js</a> ). I&#8217;ve become pretty comfortable in this instance. The errors have saved me a bit of work a number of times, by tracing an incorrect setting to Firebug, where if I hadn&#8217;t used error checking I would have let those settings fail silently. In this example though, there are not a lot of performance issues, since this is a pretty basic object in scope &#8211; but still, I do find throwing errors to be a tremendous time saver, especially when you have to utilize some library or bit of code that you haven&#8217;t used in a while.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nosredna</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271812</link>
		<dc:creator>Nosredna</dc:creator>
		<pubDate>Thu, 05 Mar 2009 16:41:08 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271812</guid>
		<description>&gt;&gt;Especially with javascript which still has a bad reputation…

It does?</description>
		<content:encoded><![CDATA[<p>&gt;&gt;Especially with javascript which still has a bad reputation…</p>
<p>It does?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: neonskimmer</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271811</link>
		<dc:creator>neonskimmer</dc:creator>
		<pubDate>Thu, 05 Mar 2009 16:14:58 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271811</guid>
		<description>There&#039;s a danger in seeing the frameworks as a kind of magic box that does things for you that you don&#039;t understand.

I&#039;m all for not reinventing the wheel, but it&#039;s definitely important as a programmer to have a modicum of understanding of the tools you are using - at least to your personal capacity if you are &#039;not quite there yet&#039;.</description>
		<content:encoded><![CDATA[<p>There&#8217;s a danger in seeing the frameworks as a kind of magic box that does things for you that you don&#8217;t understand.</p>
<p>I&#8217;m all for not reinventing the wheel, but it&#8217;s definitely important as a programmer to have a modicum of understanding of the tools you are using &#8211; at least to your personal capacity if you are &#8216;not quite there yet&#8217;.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271809</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Thu, 05 Mar 2009 16:12:17 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271809</guid>
		<description>If you work alone or with a &quot;standard&quot; library, maybe.
But in a team project, this could make the difference between hard to exploit (or even rejected) code, and good work.
Especially with javascript which still has a bad reputation... Delivering irreproachable code and taking your co-workers by the hand is sometimes necessary.</description>
		<content:encoded><![CDATA[<p>If you work alone or with a &#8220;standard&#8221; library, maybe.<br />
But in a team project, this could make the difference between hard to exploit (or even rejected) code, and good work.<br />
Especially with javascript which still has a bad reputation&#8230; Delivering irreproachable code and taking your co-workers by the hand is sometimes necessary.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: daitro</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271808</link>
		<dc:creator>daitro</dc:creator>
		<pubDate>Thu, 05 Mar 2009 15:57:03 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271808</guid>
		<description>@ywg 

I still hardly see how that would be any useful, with firebug and jslint you are pretty much covered. Any doubts? Check the docs. Simple as that. If you need a library that checks your stupidity you can try ajax.net</description>
		<content:encoded><![CDATA[<p>@ywg </p>
<p>I still hardly see how that would be any useful, with firebug and jslint you are pretty much covered. Any doubts? Check the docs. Simple as that. If you need a library that checks your stupidity you can try ajax.net</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: WillPeavy</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271806</link>
		<dc:creator>WillPeavy</dc:creator>
		<pubDate>Thu, 05 Mar 2009 15:31:59 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271806</guid>
		<description>Throwing errors would bloat libraries, and divert library developers&#039; time from projects that I think would be more useful. I would rather not have it.</description>
		<content:encoded><![CDATA[<p>Throwing errors would bloat libraries, and divert library developers&#8217; time from projects that I think would be more useful. I would rather not have it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ywg</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271805</link>
		<dc:creator>ywg</dc:creator>
		<pubDate>Thu, 05 Mar 2009 15:13:06 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271805</guid>
		<description>@braddunbar, daitro

What you need is to pass a param &quot;-debug&quot; to your build process, and flag all your debug/throw instruction.

This way you can build one clean file for maintenance, and a minified one for production.</description>
		<content:encoded><![CDATA[<p>@braddunbar, daitro</p>
<p>What you need is to pass a param &#8220;-debug&#8221; to your build process, and flag all your debug/throw instruction.</p>
<p>This way you can build one clean file for maintenance, and a minified one for production.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nosredna</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271804</link>
		<dc:creator>Nosredna</dc:creator>
		<pubDate>Thu, 05 Mar 2009 15:10:02 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271804</guid>
		<description>Until JavaScript is faster in all browsers (including IE), I don&#039;t want the JS libraries doing any extra checking. I want them to go fast. Java&#039;s VM is now pretty fast, so it can afford to do sanity checking in libraries.

However, I&#039;d gladly accept two versions of the library--a debug and a release.</description>
		<content:encoded><![CDATA[<p>Until JavaScript is faster in all browsers (including IE), I don&#8217;t want the JS libraries doing any extra checking. I want them to go fast. Java&#8217;s VM is now pretty fast, so it can afford to do sanity checking in libraries.</p>
<p>However, I&#8217;d gladly accept two versions of the library&#8211;a debug and a release.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Nosredna</title>
		<link>http://ajaxian.com/archives/the-art-of-throwing-errors-in-javascript/comment-page-1#comment-271802</link>
		<dc:creator>Nosredna</dc:creator>
		<pubDate>Thu, 05 Mar 2009 15:04:19 +0000</pubDate>
		<guid isPermaLink="false">http://ajaxian.com/?p=6177#comment-271802</guid>
		<description>&quot;You can throw an by using the throw operator&quot;

syntax error</description>
		<content:encoded><![CDATA[<p>&#8220;You can throw an by using the throw operator&#8221;</p>
<p>syntax error</p>
]]></content:encoded>
	</item>
</channel>
</rss>

