Class ExceptionHelper
ExceptionHelper provides static methods for working with exceptions
public static class ExceptionHelper
- Inheritance
-
ExceptionHelper
- Inherited Members
Methods
BuildMessage(Exception, bool)
Builds up a message, using the Message field of the specified exception as well as any InnerExceptions. Optionally excludes exception names, creating a more readable message.
public static string BuildMessage(Exception exception, bool excludeExceptionNames = false)
Parameters
exception
ExceptionThe exception.
excludeExceptionNames
boolFlag indicating whether exception names should be excluded.
Returns
- string
A combined message string.
BuildStackTrace(Exception)
Builds up a message, using the Message field of the specified exception as well as any InnerExceptions.
public static string BuildStackTrace(Exception exception)
Parameters
exception
ExceptionThe exception.
Returns
- string
A combined stack trace.
Rethrow(Exception)
Rethrows an exception, preserving its stack trace
public static void Rethrow(Exception exception)
Parameters
exception
ExceptionThe exception to rethrow
Unwrap(Exception)
Unwraps the exception of type TargetInvocationException to its InnerException.
public static Exception Unwrap(this Exception exception)
Parameters
exception
ExceptionThe exception to unwrap.
Returns
- Exception
The InnerException is available, otherwise the
exception
.