Show / Hide Table of Contents

Class ExceptionExtensions

Class that provides extension methods for the Exception class. These extension methods provide a mechanism for developers to get more easily to the root cause of an exception, especially in combination with DI-containers such as Unity.

Inheritance
System.Object
ExceptionExtensions
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Sartorius.SAF.Extensions
Assembly: Sartorius.SAF.dll
Syntax
public static class ExceptionExtensions

Methods

View Source

GetRootException(Exception)

Looks at all the inner exceptions of the exception parameter to find the most likely root cause of the exception. This works by skipping all registered exception types.

Declaration
public static Exception GetRootException(this Exception exception)
Parameters
Type Name Description
System.Exception exception

The exception that will provide the list of inner exeptions to examine.

Returns
Type Description
System.Exception

The exception that most likely caused the exception to occur. If it can't find the root exception, it will return the exception value itself.

Remarks

This method is not 100% accurate and should only be used to point a developer into the most likely direction. It should not be used to replace the Inner Exception stack of an exception, because this might hide required exception information.

View Source

IsFrameworkExceptionRegistered(Type)

Determines whether the exception type is already registered using the RegisterFrameworkExceptionType(Type) method

Declaration
public static bool IsFrameworkExceptionRegistered(Type frameworkExceptionType)
Parameters
Type Name Description
System.Type frameworkExceptionType

The type of framework exception to find.

Returns
Type Description
System.Boolean

true if the exception type is already registered; otherwise, false.

View Source

RegisterFrameworkExceptionType(Type)

Register the type of an Exception that is thrown by the framework. The GetRootException(Exception) method uses this list of Exception types to find out if something has gone wrong.

Declaration
public static void RegisterFrameworkExceptionType(Type frameworkExceptionType)
Parameters
Type Name Description
System.Type frameworkExceptionType

The type of exception to register.

  • View Source
Back to top Generated by DocFX