Table of Contents

Class ErrorHandlerExtensions

Namespace
Acuit.Pinpoint.ErrorHandling
Assembly
Acuit.Pinpoint.ErrorHandling.Abstractions.dll

Extension member helpers for IErrorHandler.

public static class ErrorHandlerExtensions
Inheritance
ErrorHandlerExtensions
Inherited Members

Methods

HandleFaultAsUnexpectedException(Task, IErrorHandler)

Adds a fault handler to the task so that it can be treated as a fire-and-forget task, immediately handling a fault as an unexpected exception.

public static void HandleFaultAsUnexpectedException(this Task task, IErrorHandler errorHandler)

Parameters

task Task
errorHandler IErrorHandler

The error handler.

Remarks

If an unobserved fire-and-forget task without this handler faults, then UnobservedTaskException will be raised, which may or may not cause HandleUnexpectedException(Exception) to be called, depending on the IErrorHandler implementation.

If the IErrorHandler implementation (or other code) does not watch UnobservedTaskException and call HandleUnexpectedException(Exception), then using HandleFaultAsUnexpectedException(Task, IErrorHandler) will cause a task fault to trigger HandleUnexpectedException(Exception) when it otherwise would not, and (depending on runtime settings), be silently eaten by the runtime.

Typically, however, the IErrorHandler implementation will watch UnobservedTaskException and call HandleUnexpectedException(Exception), so eventually those errors will be handled, when the Task finalizer runs to check for unobserved task faults. In this scenario, using HandleFaultAsUnexpectedException(Task, IErrorHandler) causes unexpected error handling to occur immediately (e.g., improving the quality of the logged error) and not on the finalizer thread (e.g., from which message boxes should not be shown).

Exceptions

ArgumentNullException

errorHandler is null.