Table of Contents

Class IErrorHandlerExtensions

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

Extension methods for IErrorHandler.

public static class IErrorHandlerExtensions
Inheritance
IErrorHandlerExtensions
Inherited Members

Methods

HandleFaultAsUnexpectedException(Task, IErrorHandler)

Add a fault handler to an asynchronous fire-and-forget task to immediately handle unhandled exceptions.

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

Parameters

task Task

The task for which to add the fault handler.

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

task is null.

ArgumentNullException

errorHandler is null.