xUnit.net
Public Member Functions | Properties | List of all members
Xunit.Sdk.ExceptionAggregator Class Reference

Aggregates exceptions. Intended to run one or more code blocks, and collect the exceptions thrown by those code blocks. More...

Public Member Functions

 ExceptionAggregator ()
 Initializes a new instance of the ExceptionAggregator class. More...
 
 ExceptionAggregator (ExceptionAggregator parent)
 Initializes a new instance of the ExceptionAggregator class that contains the exception list of its parent. More...
 
void Add (Exception ex)
 Adds an exception to the aggregator. More...
 
void Aggregate (ExceptionAggregator aggregator)
 Adds exceptions from another aggregator into this aggregator. More...
 
void Clear ()
 Clears the aggregator. More...
 
void Run (Action code)
 Runs the code, catching the exception that is thrown and adding it to the aggregate. More...
 
async Task RunAsync (Func< Task > code)
 Runs the code, catching the exception that is thrown and adding it to the aggregate. More...
 
async Task< T > RunAsync< T > (Func< Task< T >> code)
 Runs the code, catching the exception that is thrown and adding it to the aggregate. More...
 
Exception ToException ()
 Returns an exception that represents the exceptions thrown by the code passed to the Run or RunAsync method. More...
 

Properties

bool HasExceptions [get]
 Returns true if the aggregator has at least one exception inside it. More...
 

Detailed Description

Aggregates exceptions. Intended to run one or more code blocks, and collect the exceptions thrown by those code blocks.

Constructor & Destructor Documentation

◆ ExceptionAggregator() [1/2]

Xunit.Sdk.ExceptionAggregator.ExceptionAggregator ( )
inline

Initializes a new instance of the ExceptionAggregator class.

◆ ExceptionAggregator() [2/2]

Xunit.Sdk.ExceptionAggregator.ExceptionAggregator ( ExceptionAggregator  parent)
inline

Initializes a new instance of the ExceptionAggregator class that contains the exception list of its parent.

Parameters
parentThe parent aggregator to copy exceptions from.

Member Function Documentation

◆ Add()

void Xunit.Sdk.ExceptionAggregator.Add ( Exception  ex)
inline

Adds an exception to the aggregator.

Parameters
exThe exception to be added.

◆ Aggregate()

void Xunit.Sdk.ExceptionAggregator.Aggregate ( ExceptionAggregator  aggregator)
inline

Adds exceptions from another aggregator into this aggregator.

Parameters
aggregatorThe aggregator whose exceptions should be copied.

◆ Clear()

void Xunit.Sdk.ExceptionAggregator.Clear ( )
inline

Clears the aggregator.

◆ Run()

void Xunit.Sdk.ExceptionAggregator.Run ( Action  code)
inline

Runs the code, catching the exception that is thrown and adding it to the aggregate.

Parameters
codeThe code to be run.

◆ RunAsync()

async Task Xunit.Sdk.ExceptionAggregator.RunAsync ( Func< Task >  code)
inline

Runs the code, catching the exception that is thrown and adding it to the aggregate.

Parameters
codeThe code to be run.

◆ RunAsync< T >()

async Task<T> Xunit.Sdk.ExceptionAggregator.RunAsync< T > ( Func< Task< T >>  code)
inline

Runs the code, catching the exception that is thrown and adding it to the aggregate.

Parameters
codeThe code to be run.

◆ ToException()

Exception Xunit.Sdk.ExceptionAggregator.ToException ( )
inline

Returns an exception that represents the exceptions thrown by the code passed to the Run or RunAsync method.

Returns
Returns null if no exceptions were thrown; returns the exact exception if a single exception was thrown; returns AggregateException if more than one exception was thrown.

Property Documentation

◆ HasExceptions

bool Xunit.Sdk.ExceptionAggregator.HasExceptions
get

Returns true if the aggregator has at least one exception inside it.


The documentation for this class was generated from the following file: