Table of Contents

Class ExceptionHelper

Namespace
NUnit.Framework.Internal
Assembly
nunit.framework.dll

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 Exception

The exception.

excludeExceptionNames bool

Flag 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 Exception

The exception.

Returns

string

A combined stack trace.

Rethrow(Exception)

Rethrows an exception, preserving its stack trace

public static void Rethrow(Exception exception)

Parameters

exception Exception

The exception to rethrow

Unwrap(Exception)

Unwraps the exception of type TargetInvocationException to its InnerException.

public static Exception Unwrap(this Exception exception)

Parameters

exception Exception

The exception to unwrap.

Returns

Exception

The InnerException is available, otherwise the exception.