CSLA .NET

Vibrant discussion about CSLA .NET and using the framework to build great business applications.

Bug? Csla.Rules.BusinessRules.RunRules() hides Exceptions in rules

rated by 0 users
Answered (Verified) This post has 1 verified answer | 4 Replies | 0 Followers

Not Ranked
14 Posts
Holger posted on Tue, Jan 15 2013 5:07 AM

We log all unhandeled exceptions for monitoring. I have a case where an exception occurs in the business rule execute-method. We can not monitor those exception, because the BusinessRules-class does not rethrow.

There is a try-catch block in Csla.Rules.BusinessRules.RunRules() method which hides exceptions on rule execution. 

Is it possible to fix this and rethrow this exception?

try
{
   rule.Execute(context);
}
catch (Exception ex)
{
   context.AddErrorResult(string.Format("{0}:{1}", rule.RuleName, ex.Message));
   if (rule.IsAsync)
     context.Complete();

   throw;
}

 

 

Answered (Verified) Verified Answer

Top 10 Contributor
1,772 Posts
Verified by Holger

No, the only solution will require extending the rules framework to accept a custom exception logger - which is not supported at the time.

CSLA can not rethrow the exception - the rule subsystem MUST make sure to check all rules and not leave the object in an undetermined state and you may get more than one exception. Remenber also to handle a combination of sync and async rules.

Your only option - right now - is to edit the CSLA source locally to create your own CSLA version and add exception logging in BusinessRules.RunRules

Jonny Bekkum, Norway CslaContrib Coordinator

All Replies

Top 10 Contributor
1,772 Posts
Suggested by JonnyBee

An unhandled exception in a rules Execute method will be added as a broken rule to that property/object. 

We cannot allow unhandled exception in rules to be thrown as you suggest as this would stop the entire rule processing and leave the object in an indetermined state. 

Jonny Bekkum, Norway CslaContrib Coordinator

Not Ranked
14 Posts
Holger replied on Thu, Jan 17 2013 6:21 AM

Is it possible to add a setting in app.config, so that the user of the csla-framwork can decide to rethrow exceptions in rules or not?

Top 10 Contributor
1,772 Posts
Verified by Holger

No, the only solution will require extending the rules framework to accept a custom exception logger - which is not supported at the time.

CSLA can not rethrow the exception - the rule subsystem MUST make sure to check all rules and not leave the object in an undetermined state and you may get more than one exception. Remenber also to handle a combination of sync and async rules.

Your only option - right now - is to edit the CSLA source locally to create your own CSLA version and add exception logging in BusinessRules.RunRules

Jonny Bekkum, Norway CslaContrib Coordinator

Not Ranked
14 Posts
Holger replied on Wed, Jan 23 2013 1:39 AM

Ok, I think about to create my own CSLA version.

Page 1 of 1 (5 items) | RSS

Copyright (c) 2006-2010 Marimer LLC. All rights reserved.
Email admin@lhotka.net for support.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems