Class ExceptionHelper
Helper class to work with exceptions
Inherited Members
Namespace: SuperOffice.Exceptions
Assembly: SoCore.dll
Syntax
public static class ExceptionHelper
Methods
DeepMessageStack(Exception, string)
Helper class to work with exceptions
Declaration
public static string DeepMessageStack(this Exception ex, string separator = "\n")
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | ex | |
| string | separator |
Returns
| Type | Description |
|---|---|
| string |
Enumerate(SoExceptionInfo)
Enumerate over all exceptions in the tree.
Declaration
public static IEnumerable<SoExceptionInfo> Enumerate(this SoExceptionInfo exception)
Parameters
| Type | Name | Description |
|---|---|---|
| SoExceptionInfo | exception | Exception to loop over |
Returns
| Type | Description |
|---|---|
| IEnumerable<SoExceptionInfo> | All nested exceptions in the tree/loop |
Enumerate(Exception)
Enumerate over all exceptions in the tree.
Declaration
public static IEnumerable<SoExceptionInfo> Enumerate(this Exception exception)
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | exception | Exception to loop over |
Returns
| Type | Description |
|---|---|
| IEnumerable<SoExceptionInfo> | All nested exceptions in the tree/loop |
FindExceptionOfType<T>(Exception)
Recursively traverse the InnerException stack from the given starting point, and look for an element of the given type. If found, return that element, otherwise null.
Declaration
public static T FindExceptionOfType<T>(this Exception topOfStack) where T : Exception
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | topOfStack | Starting point of search |
Returns
| Type | Description |
|---|---|
| T | Strongly typed, first-found value (nearest to top of stack); or null |
Type Parameters
| Name | Description |
|---|---|
| T | Type of exception to find, for instance typeof(SoException) |
GetExceptionInfo(Exception)
Extension method retrieving a SoExceptionInfo from Exception
Declaration
public static SoExceptionInfo GetExceptionInfo(this Exception ex)
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | ex |
Returns
| Type | Description |
|---|---|
| SoExceptionInfo |
GetFriendlyText(SoExceptionInfo)
Get the friendly text from an exception. If one does not exist, return the message instead.
Declaration
public static string GetFriendlyText(this SoExceptionInfo exception)
Parameters
| Type | Name | Description |
|---|---|---|
| SoExceptionInfo | exception | The exception |
Returns
| Type | Description |
|---|---|
| string | The friendly text from an exception. If one does not exist, return the message instead. |
GetInnermostException(SoExceptionInfo)
Get the innermost exception from an exception - keeping whatever serialized exception required.
Declaration
public static SoExceptionInfo GetInnermostException(this SoExceptionInfo ex)
Parameters
| Type | Name | Description |
|---|---|---|
| SoExceptionInfo | ex | Exception to get the innermost exception from. |
Returns
| Type | Description |
|---|---|
| SoExceptionInfo | Innerm ost exception. |
GetInnermostException(Exception)
Get the innermost exception from an exception - keeping whatever serialized exception required.
Declaration
public static SoExceptionInfo GetInnermostException(this Exception ex)
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | ex | Exception to get the innermost exception from. |
Returns
| Type | Description |
|---|---|
| SoExceptionInfo | Innerm ost exception. |
SimpleMessageStack(Exception, string)
Recurse an exception and return a simple string, starting with the outermost, with one element per exception message
Declaration
public static string SimpleMessageStack(this Exception ex, string separator = "\n")
Parameters
| Type | Name | Description |
|---|---|---|
| Exception | ex | Exception to recurse |
| string | separator | Optional separator |
Returns
| Type | Description |
|---|---|
| string | Message from each exception, outermost first |
ToString(SoExceptionInfo, string, bool)
Return a compilation of all exception messages, separated by the provided seperator.
Declaration
public static string ToString(this SoExceptionInfo exception, string seperator, bool includeType)
Parameters
| Type | Name | Description |
|---|---|---|
| SoExceptionInfo | exception | Exeption to get details for. |
| string | seperator | Seperator to seperate the exception. |
| bool | includeType | Include the type of exceptions as part of the message. |
Returns
| Type | Description |
|---|---|
| string | A compilation of all exception messages, seperated by the provided seperator. |
TryGetRealType(SoExceptionInfo, out Type)
Try to get the real type encapsulated in ExceptionType.
Declaration
public static bool TryGetRealType(this SoExceptionInfo ex, out Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| SoExceptionInfo | ex | |
| Type | type |
Returns
| Type | Description |
|---|---|
| bool |