Table of Contents

Class ExceptionExtensions

Namespace
Plugin.BaseTypeExtensions
Assembly
Plugin.BaseTypeExtensions.dll

Provides extension methods for Exception analysis and utility functions.

public static class ExceptionExtensions
Inheritance
ExceptionExtensions
Inherited Members

Methods

GetExceptionData(Exception)

Gets all exception data as a dictionary.

public static Dictionary<string, object> GetExceptionData(this Exception exception)

Parameters

exception Exception

The exception to analyze.

Returns

Dictionary<string, object>

A dictionary containing all exception data.

Exceptions

ArgumentNullException

Thrown when exception is null.

GetFullMessage(Exception)

Gets the full exception message including all inner exceptions.

public static string GetFullMessage(this Exception exception)

Parameters

exception Exception

The exception to analyze.

Returns

string

A string containing the full exception message chain.

Exceptions

ArgumentNullException

Thrown when exception is null.

GetInnerException<T>(Exception)

Finds the first inner exception of the specified type.

public static T? GetInnerException<T>(this Exception exception) where T : Exception

Parameters

exception Exception

The exception to search.

Returns

T

The first inner exception of the specified type, or null if not found.

Type Parameters

T

The type of exception to find.

Exceptions

ArgumentNullException

Thrown when exception is null.

GetInnerExceptions(Exception)

Gets all inner exceptions in the exception chain.

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

Parameters

exception Exception

The exception to analyze.

Returns

IEnumerable<Exception>

An enumerable of all inner exceptions.

Exceptions

ArgumentNullException

Thrown when exception is null.

GetInnermostException(Exception)

Gets the innermost exception in the exception chain.

public static Exception GetInnermostException(this Exception exception)

Parameters

exception Exception

The exception to analyze.

Returns

Exception

The innermost exception, or the original exception if no inner exceptions exist.

Exceptions

ArgumentNullException

Thrown when exception is null.

GetStackTraceWithoutSystemCalls(Exception)

Gets the stack trace with system calls filtered out for cleaner debugging.

public static string GetStackTraceWithoutSystemCalls(this Exception exception)

Parameters

exception Exception

The exception to analyze.

Returns

string

A filtered stack trace string.

Exceptions

ArgumentNullException

Thrown when exception is null.

HasInnerException<T>(Exception)

Determines whether the exception chain contains an inner exception of the specified type.

public static bool HasInnerException<T>(this Exception exception) where T : Exception

Parameters

exception Exception

The exception to check.

Returns

bool

True if an inner exception of the specified type exists; otherwise, false.

Type Parameters

T

The type of exception to check for.

Exceptions

ArgumentNullException

Thrown when exception is null.

IsFatal(Exception)

Determines whether the exception is considered fatal and should not be caught.

public static bool IsFatal(this Exception exception)

Parameters

exception Exception

The exception to check.

Returns

bool

True if the exception is fatal; otherwise, false.

Exceptions

ArgumentNullException

Thrown when exception is null.

ToLogString(Exception)

Formats the exception for logging purposes with comprehensive information.

public static string ToLogString(this Exception exception)

Parameters

exception Exception

The exception to format.

Returns

string

A formatted string suitable for logging.

Exceptions

ArgumentNullException

Thrown when exception is null.