AuditProblem Class

Assembly: CodeEffects.Rule.Audit.dll
Namespace: CodeEffects.Rule.Audit

Summary

Describes something that went wrong inside an AuditRecorder, as it is reported to the host.

Syntax

public class AuditProblem

Remarks

You never create this class. The recorder never throws into an evaluation, nor from its background work, with the exception of the AuditException that ThrowOnStoreFailure asks for. Instead it passes an AuditProblem to the delegate you assign to AuditSettings.OnProblem. With no delegate, nothing is reported.

The delegate may be called on the evaluating thread or on the recorder's background thread, so it must be thread-safe and quick. An exception thrown by the delegate is ignored. Use Kind to decide what to do, and Message and Exception to log it.

Properties

  • Exception

    Type: System.Exception

    Gets the exception behind the problem, such as the exception that the database threw, or null when there is none.

  • Kind

    Type: CodeEffects.Rule.Audit.AuditProblemKind

    Gets what went wrong.

  • Message

    Type: System.String

    Gets what went wrong, in words.

Methods

  • ToString()

    Returns: System.String - The kind and the message, separated by a colon.

    public override string ToString()

    Returns the kind and the message as one string, such as DrainFailed: ....

Example

using CodeEffects.Rule.Audit;

var settings = new AuditSettings
{
	OnProblem = problem =>
	{
		switch (problem.Kind)
		{
			case AuditProblemKind.JournalFull:
			case AuditProblemKind.QueueFull:
				logger.LogWarning("Audit is dropping records: " + problem.Message);
				break;
			default:
				logger.LogWarning(problem.ToString());
				break;
		}
	}
};

Ask on Stack Overflow - Yes, it's still active
Ask in GitHub Discussions

p102

l097 --

l102

p101

×