<?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: No Exceptions &#8211; With One Exception</title>
	<atom:link href="http://marknelson.us/2007/11/13/no-exceptions/feed/" rel="self" type="application/rss+xml" />
	<link>http://marknelson.us/2007/11/13/no-exceptions/</link>
	<description>Programming, mostly.</description>
	<lastBuildDate>Sun, 20 May 2012 20:52:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
	<item>
		<title>By: c++: error VS C++ VS Linux C++: std::stringstream is non-copyable. &#171; Talueee&#039;s Blog</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-356066</link>
		<dc:creator>c++: error VS C++ VS Linux C++: std::stringstream is non-copyable. &#171; Talueee&#039;s Blog</dc:creator>
		<pubDate>Wed, 27 Apr 2011 10:14:35 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-356066</guid>
		<description>[...] More about this topic:  Link  [...]</description>
		<content:encoded><![CDATA[<p>[...] More about this topic:  Link  [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: evilteach</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-320000</link>
		<dc:creator>evilteach</dc:creator>
		<pubDate>Mon, 14 Dec 2009 16:49:51 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-320000</guid>
		<description>I am impressed.  This is what I have been trying to do this week.  The trick of inserting the message into the copy of the object, bypasses the hole inheriting from a stream class that has no copy constructor.

Well done.</description>
		<content:encoded><![CDATA[<p>I am impressed.  This is what I have been trying to do this week.  The trick of inserting the message into the copy of the object, bypasses the hole inheriting from a stream class that has no copy constructor.</p>
<p>Well done.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark Nelson</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-222157</link>
		<dc:creator>Mark Nelson</dc:creator>
		<pubDate>Sun, 05 Oct 2008 18:39:47 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-222157</guid>
		<description>@Alan:

Ummm... try as I might I don&#039;t see any references to Windows 98 or XP in the article

http://marknelson.us/1992/05/01/file-verification-using-crc-2/

Tell me, why did you post the comment here instead of in the comments section on that article?

- Mark</description>
		<content:encoded><![CDATA[<p>@Alan:</p>
<p>Ummm&#8230; try as I might I don&#8217;t see any references to Windows 98 or XP in the article</p>
<p><a href="http://marknelson.us/1992/05/01/file-verification-using-crc-2/" rel="nofollow">http://marknelson.us/1992/05/01/file-verification-using-crc-2/</a></p>
<p>Tell me, why did you post the comment here instead of in the comments section on that article?</p>
<p>- Mark</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alan Morris</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-222085</link>
		<dc:creator>Alan Morris</dc:creator>
		<pubDate>Sun, 05 Oct 2008 14:34:41 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-222085</guid>
		<description>Dear Mark:

You article &quot;File Verification Using CRC&quot; is dated May 1992,
but in the article you refer to Windows 98 and to Windows XP.
Is there an error in the dating of the article?</description>
		<content:encoded><![CDATA[<p>Dear Mark:</p>
<p>You article &#8220;File Verification Using CRC&#8221; is dated May 1992,<br />
but in the article you refer to Windows 98 and to Windows XP.<br />
Is there an error in the dating of the article?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-47514</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 21 Nov 2007 23:28:07 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-47514</guid>
		<description>apologies - my response was mangled.

DBG_ERROR( &quot;can you believe this: &quot; &lt;&lt; someString &lt;&lt; &quot;is not null!?&quot; );

I prefer the sprintf format but that is still pretty clean.

The next part was just an obvious point that DBG_ASSERT could expand to your example code or several other forms.  That is it&#039;s chief strength above your example.</description>
		<content:encoded><![CDATA[<p>apologies &#8211; my response was mangled.</p>
<p>DBG_ERROR( &#8220;can you believe this: &#8221; << someString << &#8220;is not null!?&#8221; );</p>
<p>I prefer the sprintf format but that is still pretty clean.</p>
<p>The next part was just an obvious point that DBG_ASSERT could expand to your example code or several other forms.  That is it&#8217;s chief strength above your example.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-47512</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 21 Nov 2007 23:22:21 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-47512</guid>
		<description>Another advantage of the macro approach is one can alter the macro if one wants different behaviour as you mention.  If you want a throw instead of a hardware breakpoint you can change the define and not code spread throughout the app.  A good suggestion is to change it based on the build target (e.g. hardware breakpoint in DEBUG, throw on RELEASE).

The sprintf format is just one example.  I&#039;ve also seen DBG_ERROR( &quot;can you believe this: &quot; 
DBG_ASSERT( !somethingBad, &quot;Fatal error message&quot; )
&lt;/code&gt;

can easily be expanded to:
&lt;code&gt;
if (something bad)
    throw FATAL_ERROR
&lt;/code&gt;

or to several other better implementations.</description>
		<content:encoded><![CDATA[<p>Another advantage of the macro approach is one can alter the macro if one wants different behaviour as you mention.  If you want a throw instead of a hardware breakpoint you can change the define and not code spread throughout the app.  A good suggestion is to change it based on the build target (e.g. hardware breakpoint in DEBUG, throw on RELEASE).</p>
<p>The sprintf format is just one example.  I&#8217;ve also seen DBG_ERROR( &#8220;can you believe this: &#8221;<br />
DBG_ASSERT( !somethingBad, &#8220;Fatal error message&#8221; )</p>
<p>can easily be expanded to:<br />
<code><br />
if (something bad)<br />
    throw FATAL_ERROR<br />
</code></p>
<p>or to several other better implementations.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-47503</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Wed, 21 Nov 2007 22:27:29 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-47503</guid>
		<description>@James:

I won&#039;t argue that there isn&#039;t more than one way to skin this cat - although these two approaches seem fairly equivalent to me.

A minor note: the DEBUG_ASSERT you show uses sprint() type argument formatting, and one of the reasons for this particular class was to be able to take advantage of std::ostream formatting  - not that DEBUG_ASSERT couldn&#039;t have a version that does this.

As for fatal error handling in production program, DEBUG_ASSERT may or may not ultimately throw, which we hope will unwind the stack and clean up as much as possible on exit. If DEBUG_ASSERT wraps up by calling assert(), you are hosed on production.

As for picking up the __FILE__ and __LINE__, that can be done pretty easily here too - although it obviously requires invocation of the preprocessor, so your code looks like this:
[cpp]
if (something bad)
    throw FATAL_ERROR </description>
		<content:encoded><![CDATA[<p>@James:</p>
<p>I won&#8217;t argue that there isn&#8217;t more than one way to skin this cat &#8211; although these two approaches seem fairly equivalent to me.</p>
<p>A minor note: the DEBUG_ASSERT you show uses sprint() type argument formatting, and one of the reasons for this particular class was to be able to take advantage of std::ostream formatting  &#8211; not that DEBUG_ASSERT couldn&#8217;t have a version that does this.</p>
<p>As for fatal error handling in production program, DEBUG_ASSERT may or may not ultimately throw, which we hope will unwind the stack and clean up as much as possible on exit. If DEBUG_ASSERT wraps up by calling assert(), you are hosed on production.</p>
<p>As for picking up the __FILE__ and __LINE__, that can be done pretty easily here too &#8211; although it obviously requires invocation of the preprocessor, so your code looks like this:<br />
[cpp]<br />
if (something bad)<br />
    throw FATAL_ERROR</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: James</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-47501</link>
		<dc:creator>James</dc:creator>
		<pubDate>Wed, 21 Nov 2007 22:02:50 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-47501</guid>
		<description>Most projects I work on have a DEBUG_ASSERT( cond, msg, ... ) and a DEBUG_ERROR(msg, ...) macro.  Some advantages: macro expansion of the line and file the error occured on - trigger a breakpoint (most debuggers can catch a line of assembly to go into the debugger) - compiles clean out.

&lt;code&gt;
DEBUG_ERROR( &quot;Uh oh, if your in this branch your broke!&quot; );
DEBUG_ASSERT( pObj, &quot;Null pointer!&quot; );
DEBUG_ASSERT( a == b, &quot;a doesn&#039;t equal b cause b is %1&quot;, b );
&lt;/code&gt;

I think you will find this method provides the benefits of your approach plus much, much more.

In languages that do not support C pre-processor style macros, I use a wrapper around throw to achieve the same thing.</description>
		<content:encoded><![CDATA[<p>Most projects I work on have a DEBUG_ASSERT( cond, msg, &#8230; ) and a DEBUG_ERROR(msg, &#8230;) macro.  Some advantages: macro expansion of the line and file the error occured on &#8211; trigger a breakpoint (most debuggers can catch a line of assembly to go into the debugger) &#8211; compiles clean out.</p>
<p><code><br />
DEBUG_ERROR( "Uh oh, if your in this branch your broke!" );<br />
DEBUG_ASSERT( pObj, "Null pointer!" );<br />
DEBUG_ASSERT( a == b, "a doesn't equal b cause b is %1", b );<br />
</code></p>
<p>I think you will find this method provides the benefits of your approach plus much, much more.</p>
<p>In languages that do not support C pre-processor style macros, I use a wrapper around throw to achieve the same thing.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Mark</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-47430</link>
		<dc:creator>Mark</dc:creator>
		<pubDate>Wed, 21 Nov 2007 18:02:19 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-47430</guid>
		<description>@dk:

Consider this to be a replacement for assert(). If you look at the one minor example, you&#039;ll see that I throw an exception when command line arguments are missing. Not really a bug in my program, but a good reason to stop.

This kind of exception can only really be used when your program is more or less sane. It is not likely to be useful in a case where your program loses its sanity. For one thing, this is usually not something you can predict, so you aren&#039;t going to be writing conditional code to detect the condition and throw an exception.

So this is useful for things like &quot;file not found&quot;, &quot;unable to   open network port&quot;, &quot;database appears to have lost consistency&quot;. Not so much for bad pointer, memory leak, mismatched libraries, etc.

It&#039;s just one tool among many that you might use to handle errors in a production program.</description>
		<content:encoded><![CDATA[<p>@dk:</p>
<p>Consider this to be a replacement for assert(). If you look at the one minor example, you&#8217;ll see that I throw an exception when command line arguments are missing. Not really a bug in my program, but a good reason to stop.</p>
<p>This kind of exception can only really be used when your program is more or less sane. It is not likely to be useful in a case where your program loses its sanity. For one thing, this is usually not something you can predict, so you aren&#8217;t going to be writing conditional code to detect the condition and throw an exception.</p>
<p>So this is useful for things like &#8220;file not found&#8221;, &#8220;unable to   open network port&#8221;, &#8220;database appears to have lost consistency&#8221;. Not so much for bad pointer, memory leak, mismatched libraries, etc.</p>
<p>It&#8217;s just one tool among many that you might use to handle errors in a production program.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: dk</title>
		<link>http://marknelson.us/2007/11/13/no-exceptions/comment-page-1/#comment-47427</link>
		<dc:creator>dk</dc:creator>
		<pubDate>Wed, 21 Nov 2007 17:55:44 +0000</pubDate>
		<guid isPermaLink="false">http://marknelson.us/2007/11/20/no-exceptions/#comment-47427</guid>
		<description>Does this mean that you don&#039;t consider fatal errors to be the result of bugs in your code? I realize that systems can run out of memory, have hardware problems and other unpredictable scenarios, but the vast majority of fatal errors in an application are caused by bugs in the application.

I prefer that my programs actually crash at the point of a fatal error. It allows customers to create and send crash dumps and allows me to see exactly what was happening at the point of failure. Any &#039;fatal condition&#039; handling loses some data that would help in diagnosing.</description>
		<content:encoded><![CDATA[<p>Does this mean that you don&#8217;t consider fatal errors to be the result of bugs in your code? I realize that systems can run out of memory, have hardware problems and other unpredictable scenarios, but the vast majority of fatal errors in an application are caused by bugs in the application.</p>
<p>I prefer that my programs actually crash at the point of a fatal error. It allows customers to create and send crash dumps and allows me to see exactly what was happening at the point of failure. Any &#8216;fatal condition&#8217; handling loses some data that would help in diagnosing.</p>
]]></content:encoded>
	</item>
</channel>
</rss>

