Table of Contents

Class ExceptionExtensions

Namespace
Acuit.Pinpoint.Common
Assembly
Acuit.Pinpoint.Common.dll

Extension members for Exception.

public static class ExceptionExtensions
Inheritance
ExceptionExtensions
Inherited Members

Methods

EnumerateFlattenedHierarchy(Exception)

Enumerates a flattened inner exceptions hierarchy for an exception.

public static IEnumerable<Exception> EnumerateFlattenedHierarchy(this Exception exception)

Parameters

exception Exception

Returns

IEnumerable<Exception>

An enumerable of exception objects.

Remarks

For AggregateExceptions, all inner exceptions are traversed; for all other exception types, any inner exceptions are traversed.

MessagesHierarchyAsMultipleLines(Exception)

Combines the messages from an exception and all inner exception(s) into a multiline string suitable for display.

public static string MessagesHierarchyAsMultipleLines(this Exception exception)

Parameters

exception Exception

Returns

string

The formatted string.

Remarks

This formats the string using MessagesHierarchyForDisplay(Exception, string, string?) with NewLine as the separator and no newline sequence replacement.

MessagesHierarchyAsSingleLine(Exception)

Combines the messages from an exception and all inner exception(s) into a one-line string suitable for display.

public static string MessagesHierarchyAsSingleLine(this Exception exception)

Parameters

exception Exception

Returns

string

The formatted string.

Remarks

This formats the string using MessagesHierarchyForDisplay(Exception, string, string?) with a single space as the separator and as the newline sequence replacement.

MessagesHierarchyForDisplay(Exception, string, string?)

Combines the messages from an exception and all inner exception(s) into a string suitable for display.

public static string MessagesHierarchyForDisplay(this Exception exception, string separator, string? newLineReplacement)

Parameters

exception Exception
separator string

The separator to use.

newLineReplacement string

The replacement to use for any newline sequences within any exception messages, or null to leave them as-is.

Returns

string

The formatted string.

Remarks

The Message value from all exceptions in the exception hierachy are combined into one line, with separator separating each exception message. For AggregateException exceptions, all inner exceptions are traversed; for all other exception types, InnerException is traversed.

Repeated exception messages are omitted, unless they are separated by other messages.

The Message value from AggregateException exceptions will not be included in the resulting string if it starts with the default value for AggregateException.Message for the current thread culture (as it is a generic message like "One or more errors occurred.").

If newLineReplacement is not null, any newline sequences in exception messages will be replaced with newLineReplacement.

Exceptions

ArgumentNullException

separator is null.

MessagesHierarchyForDisplayEquals(Exception, Exception?)

Determines whether the messages hierarchy for display of an exception equals that of another exception.

public static bool MessagesHierarchyForDisplayEquals(this Exception exception, Exception? other)

Parameters

exception Exception
other Exception

The other exception.

Returns

bool

true if other is not null and its messages hierarchy for display equals that of this exception.