<?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 BusinessException pattern</title>
	<atom:link href="http://www.inze.be/andries/2008/08/18/the-businessexception-pattern/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.inze.be/andries/2008/08/18/the-businessexception-pattern/</link>
	<description>Java, Project Management, Life and anything else.</description>
	<lastBuildDate>Wed, 10 Mar 2010 09:54:31 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jurgen Lust</title>
		<link>http://www.inze.be/andries/2008/08/18/the-businessexception-pattern/comment-page-1/#comment-195</link>
		<dc:creator>Jurgen Lust</dc:creator>
		<pubDate>Fri, 21 Nov 2008 09:21:56 +0000</pubDate>
		<guid isPermaLink="false">http://www.inze.be/andries/?p=41#comment-195</guid>
		<description>Hi Andries,

Thanks for this simple but powerful pattern. I&#039;ve integrated it in our in-house development framework, with some WebFlow support in the form of an ExceptionHandler. When a Business Exception is thrown, the ExceptionHandler catches it and puts an error message in the SWF MessageContext, which is then displayed on screen using the JSF
 tag. Other exceptions are not caught and result in a default error page, which is fine, since these are usually the result of a programming error. Perhaps an extra SystemException class could be added for exceptions that are not BusinessExceptions but also not the result of a programming error, for example when the network is down, or the database is unavailable. These should also result in a nice error message for the user, with the possibility to try again later.</description>
		<content:encoded><![CDATA[<p>Hi Andries,</p>
<p>Thanks for this simple but powerful pattern. I&#8217;ve integrated it in our in-house development framework, with some WebFlow support in the form of an ExceptionHandler. When a Business Exception is thrown, the ExceptionHandler catches it and puts an error message in the SWF MessageContext, which is then displayed on screen using the JSF<br />
 tag. Other exceptions are not caught and result in a default error page, which is fine, since these are usually the result of a programming error. Perhaps an extra SystemException class could be added for exceptions that are not BusinessExceptions but also not the result of a programming error, for example when the network is down, or the database is unavailable. These should also result in a nice error message for the user, with the possibility to try again later.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andries Inzé</title>
		<link>http://www.inze.be/andries/2008/08/18/the-businessexception-pattern/comment-page-1/#comment-180</link>
		<dc:creator>Andries Inzé</dc:creator>
		<pubDate>Sun, 14 Sep 2008 10:24:12 +0000</pubDate>
		<guid isPermaLink="false">http://www.inze.be/andries/?p=41#comment-180</guid>
		<description>You do make a valid point that the key+argument will be part of your service layer.

The whole point of this setup is to NOT make the view layer aware for each and every new exception that might pop up.

However your point does have merit. I&#039;m thinking in the lines of creating a utility/aspect that will translate all the different exceptions into an generic business exception that can be shown in the view layer. That way the service layer can throw individual different exceptions, the utility class knows how to show these on the screen and can use the context to build the appropriate exception. The controller then recieves a generic exception, with all the information. He does not need to know what particular subclass was thrown.</description>
		<content:encoded><![CDATA[<p>You do make a valid point that the key+argument will be part of your service layer.</p>
<p>The whole point of this setup is to NOT make the view layer aware for each and every new exception that might pop up.</p>
<p>However your point does have merit. I&#8217;m thinking in the lines of creating a utility/aspect that will translate all the different exceptions into an generic business exception that can be shown in the view layer. That way the service layer can throw individual different exceptions, the utility class knows how to show these on the screen and can use the context to build the appropriate exception. The controller then recieves a generic exception, with all the information. He does not need to know what particular subclass was thrown.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Stefaan Huysentruyt</title>
		<link>http://www.inze.be/andries/2008/08/18/the-businessexception-pattern/comment-page-1/#comment-179</link>
		<dc:creator>Stefaan Huysentruyt</dc:creator>
		<pubDate>Sun, 14 Sep 2008 09:42:05 +0000</pubDate>
		<guid isPermaLink="false">http://www.inze.be/andries/?p=41#comment-179</guid>
		<description>I don&#039;t agree completely.  

Sometimes the exception message is more than just an argument substitute construct.  The message is possibly calculated from the number and type of the arguments, and a the responsibility of the presentation logic only.

Therefor I rather create a GenericBusinessException, or even better: GenericDomainException and - if appropriate - start subclassing from these.  Why ?  Because otherwise (using a key + arguments) presentation logic starts creeping into the service or domain level.  Let me explain.

The sub-classed GenericDomainException is a full fledged domain object, with its own interface which exposes the context of the exception.
This domain exception is used in a presentation in the presentation layer, which retrieves the context from the exception and links it with some presentation logic.

Maybe I should clarify with some code.  But it &#039;s sunday, and I&#039;m well off bounds already here. ;-)</description>
		<content:encoded><![CDATA[<p>I don&#8217;t agree completely.  </p>
<p>Sometimes the exception message is more than just an argument substitute construct.  The message is possibly calculated from the number and type of the arguments, and a the responsibility of the presentation logic only.</p>
<p>Therefor I rather create a GenericBusinessException, or even better: GenericDomainException and &#8211; if appropriate &#8211; start subclassing from these.  Why ?  Because otherwise (using a key + arguments) presentation logic starts creeping into the service or domain level.  Let me explain.</p>
<p>The sub-classed GenericDomainException is a full fledged domain object, with its own interface which exposes the context of the exception.<br />
This domain exception is used in a presentation in the presentation layer, which retrieves the context from the exception and links it with some presentation logic.</p>
<p>Maybe I should clarify with some code.  But it &#8217;s sunday, and I&#8217;m well off bounds already here. <img src='http://www.inze.be/andries/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Thales Melo</title>
		<link>http://www.inze.be/andries/2008/08/18/the-businessexception-pattern/comment-page-1/#comment-171</link>
		<dc:creator>Thales Melo</dc:creator>
		<pubDate>Wed, 03 Sep 2008 14:25:46 +0000</pubDate>
		<guid isPermaLink="false">http://www.inze.be/andries/?p=41#comment-171</guid>
		<description>Its a good solution, but can i show some snnipet or code example?</description>
		<content:encoded><![CDATA[<p>Its a good solution, but can i show some snnipet or code example?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Andries Inzé</title>
		<link>http://www.inze.be/andries/2008/08/18/the-businessexception-pattern/comment-page-1/#comment-160</link>
		<dc:creator>Andries Inzé</dc:creator>
		<pubDate>Thu, 21 Aug 2008 15:45:47 +0000</pubDate>
		<guid isPermaLink="false">http://www.inze.be/andries/?p=41#comment-160</guid>
		<description>Johan, 

You have a good point there. It would be possible to expand the BusinessException with some list of arguments to be inserted into the translated key. 
Most messageSource implementations can substitute stuff like {0} with an argument list.</description>
		<content:encoded><![CDATA[<p>Johan, </p>
<p>You have a good point there. It would be possible to expand the BusinessException with some list of arguments to be inserted into the translated key.<br />
Most messageSource implementations can substitute stuff like {0} with an argument list.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Johan Vosloo</title>
		<link>http://www.inze.be/andries/2008/08/18/the-businessexception-pattern/comment-page-1/#comment-158</link>
		<dc:creator>Johan Vosloo</dc:creator>
		<pubDate>Thu, 21 Aug 2008 12:19:09 +0000</pubDate>
		<guid isPermaLink="false">http://www.inze.be/andries/?p=41#comment-158</guid>
		<description>Two questions:

1. Presumably the code property is used to look up a matching key to a user message, in something like an ApplicationResources.properties file?

2. Assuming the 1st approach is used, how would you present more informative error messages to the user, where parts of the message consists of dynamically substituted business values e.g. &quot;Your current balance is x, which is too low to purchase the item request&quot; - where x is the customer&#039;s account balance?</description>
		<content:encoded><![CDATA[<p>Two questions:</p>
<p>1. Presumably the code property is used to look up a matching key to a user message, in something like an ApplicationResources.properties file?</p>
<p>2. Assuming the 1st approach is used, how would you present more informative error messages to the user, where parts of the message consists of dynamically substituted business values e.g. &#8220;Your current balance is x, which is too low to purchase the item request&#8221; &#8211; where x is the customer&#8217;s account balance?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: sun007</title>
		<link>http://www.inze.be/andries/2008/08/18/the-businessexception-pattern/comment-page-1/#comment-157</link>
		<dc:creator>sun007</dc:creator>
		<pubDate>Wed, 20 Aug 2008 01:26:41 +0000</pubDate>
		<guid isPermaLink="false">http://www.inze.be/andries/?p=41#comment-157</guid>
		<description>Hi,
  Great post.Can you please show some sample code how you use BusinessException.</description>
		<content:encoded><![CDATA[<p>Hi,<br />
  Great post.Can you please show some sample code how you use BusinessException.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
