Show / Hide Table of Contents

Class ExceptionHelper

Helper class to work with exceptions

Inheritance
Object
ExceptionHelper
Inherited Members
Object.ToString()
Object.Equals(Object)
Object.Equals(Object, Object)
Object.ReferenceEquals(Object, Object)
Object.GetHashCode()
Object.GetType()
Object.MemberwiseClone()
Namespace: SuperOffice.Exceptions
Assembly: SoCore.dll
Syntax
public static class ExceptionHelper

Methods

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, Boolean)

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.

Boolean 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
Boolean
© SuperOffice. All rights reserved.
SuperOffice |  Community |  Release Notes |  Privacy |  Site feedback |  Search Docs |  About Docs |  Contribute |  Back to top