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
Namespace: Sartorius.SAF.Extensions
Assembly: Sartorius.SAF.dll
Syntax
public static class ExceptionExtensions
Methods
View SourceGetRootException(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
|
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.
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 |
|
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. |