Show / Hide Table of Contents

Class ExceptionAggregator

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

Inheritance
Object
ExceptionAggregator
Namespace: Xunit.Sdk
Assembly: xunit.core.dll
Syntax
public class ExceptionAggregator : object

Constructors

| Improve this Doc View Source

ExceptionAggregator()

Initializes a new instance of the ExceptionAggregator class.

Declaration
public ExceptionAggregator()
| Improve this Doc View Source

ExceptionAggregator(ExceptionAggregator)

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

Declaration
public ExceptionAggregator(ExceptionAggregator parent)
Parameters
Type Name Description
ExceptionAggregator parent

The parent aggregator to copy exceptions from.

Properties

| Improve this Doc View Source

HasExceptions

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

Declaration
public bool HasExceptions { get; }
Property Value
Type Description
Boolean

Methods

| Improve this Doc View Source

Add(Exception)

Adds an exception to the aggregator.

Declaration
public void Add(Exception ex)
Parameters
Type Name Description
Exception ex

The exception to be added.

| Improve this Doc View Source

Aggregate(ExceptionAggregator)

Adds exceptions from another aggregator into this aggregator.

Declaration
public void Aggregate(ExceptionAggregator aggregator)
Parameters
Type Name Description
ExceptionAggregator aggregator

The aggregator whose exceptions should be copied.

| Improve this Doc View Source

Clear()

Clears the aggregator.

Declaration
public void Clear()
| Improve this Doc View Source

Run(Action)

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

Declaration
public void Run(Action code)
Parameters
Type Name Description
Action code

The code to be run.

| Improve this Doc View Source

RunAsync(Func<Task>)

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

Declaration
public Task RunAsync(Func<Task> code)
Parameters
Type Name Description
Func<Task> code

The code to be run.

Returns
Type Description
Task
| Improve this Doc View Source

RunAsync<T>(Func<Task<T>>)

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

Declaration
public Task<T> RunAsync<T>(Func<Task<T>> code)
Parameters
Type Name Description
Func<Task<T>> code

The code to be run.

Returns
Type Description
Task<T>
Type Parameters
Name Description
T
| Improve this Doc View Source

ToException()

Returns an exception that represents the exceptions thrown by the code passed to the Run(Action) or RunAsync(Func<Task>) method.

Declaration
public Exception ToException()
Returns
Type Description
Exception

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

  • Improve this Doc
  • View Source
Back to top Generated by DocFX