AuditException Class
Assembly: CodeEffects.Rule.Audit.dll
Namespace: CodeEffects.Rule.Audit
Summary
Represents the error that an evaluation throws when its record could not be written to the database and you asked for that evaluation to fail.
Syntax
public class AuditException : System.Exception
The exception is thrown to the code that evaluates the rule, and only when Mode is Synchronous and ThrowOnStoreFailure is true. The result of the evaluation is not returned, so a decision that must not be acted on unless it is recorded is not acted on. The exception of the database is the InnerException. The same failure is also reported to OnProblem as AuditProblemKind.StoreFailed.
A rule that throws always throws its own exception, never this one. In every other configuration the recorder never throws into an evaluation: it reports problems to OnProblem only. You normally never create this class.
Inheritance
System.Object
System.Exception
- CodeEffects.Rule.Audit.AuditException
Constructors
AuditException(string)
Initializes a new instance of the AuditException class with the specified error message.
Parameters
- message (
System.String) - The error message.
AuditException(string, Exception)
Initializes a new instance of the AuditException class with the specified error message and the exception that caused it.
Parameters
- message (
System.String) - The error message.
- innerException (
System.Exception) - The exception that is the cause of this exception. It becomes the value of the InnerException property.
Example
using CodeEffects.Rule.Audit;
using CodeEffects.Rule.Common.Models;
using CodeEffects.Rule.Engine;
var audit = new AuditRecorder(dbProvider, new AuditSettings
{
Mode = AuditMode.Synchronous,
ThrowOnStoreFailure = true
});
AuditRuleset ruleset = audit.GetRules(RuleQuery.BySource("Order"));
var parameters = new EvaluationParameters();
audit.Attach(parameters);
var evaluator = new Evaluator<Order>(ruleset.Xml, parameters);
try
{
bool approved = evaluator.Evaluate(order, ruleset.Rule("Approve large orders").Id);
}
catch (AuditException ex)
{
// The decision was not recorded, so do not act on it
Console.WriteLine(ex.Message + " / " + ex.InnerException);
}