Table of Contents

Class HttpExceptionDescriptorResponseFormatter<TOptions>

Namespace
Cuemon.AspNetCore.Diagnostics
Assembly
Cuemon.AspNetCore.dll

Provides a generic way to support content negotiation for exceptions in the application.

public class HttpExceptionDescriptorResponseFormatter<TOptions> : Configurable<TOptions>, IConfigurable<TOptions>, IHttpExceptionDescriptorResponseFormatter where TOptions : class, IContentNegotiation, IParameterObject, new()

Type Parameters

TOptions

The type of the options to configure.

Inheritance
Configurable<TOptions>
HttpExceptionDescriptorResponseFormatter<TOptions>
Implements
IConfigurable<TOptions>
Inherited Members

Constructors

HttpExceptionDescriptorResponseFormatter(TOptions)

Initializes a new instance of the HttpExceptionDescriptorResponseFormatter<TOptions> class.

public HttpExceptionDescriptorResponseFormatter(TOptions options)

Parameters

options TOptions

The configured options of this instance.

Exceptions

ArgumentNullException

options cannot be null.

ArgumentException

options are not in a valid state.

HttpExceptionDescriptorResponseFormatter(IOptions<TOptions>)

Initializes a new instance of the HttpExceptionDescriptorResponseFormatter<TOptions> class.

public HttpExceptionDescriptorResponseFormatter(IOptions<TOptions> options)

Parameters

options IOptions<TOptions>

The IOptions<TOptions> which need to be configured.

Exceptions

ArgumentNullException

options cannot be null.

ArgumentException

options are not in a valid state.

HttpExceptionDescriptorResponseFormatter(Action<TOptions>)

Initializes a new instance of the HttpExceptionDescriptorResponseFormatter<TOptions> class.

public HttpExceptionDescriptorResponseFormatter(Action<TOptions> setup)

Parameters

setup Action<TOptions>

The Action<T> which need to be configured.

Exceptions

ArgumentException

setup could not be configured to a valid state.

Properties

ExceptionDescriptorHandlers

Gets the collection of populated HttpExceptionDescriptorResponseHandler instances.

public ICollection<HttpExceptionDescriptorResponseHandler> ExceptionDescriptorHandlers { get; }

Property Value

ICollection<HttpExceptionDescriptorResponseHandler>

The collection of populated HttpExceptionDescriptorResponseHandler instances.

Methods

Adjust(Action<TOptions>)

Adjusts the Options to your liking.

public HttpExceptionDescriptorResponseFormatter<TOptions> Adjust(Action<TOptions> setup)

Parameters

setup Action<TOptions>

The Action<T> which need to be configured.

Returns

HttpExceptionDescriptorResponseFormatter<TOptions>

A reference to this instance so that additional calls can be chained.

Exceptions

ArgumentException

setup could not be configured to a valid state.

Populate(Func<HttpExceptionDescriptor, MediaTypeHeaderValue, HttpContent>, ICollection<HttpExceptionDescriptorResponseHandler>)

Populates the underlying SupportedMediaTypes to the ExceptionDescriptorHandlers using the specified contentFactory.

public HttpExceptionDescriptorResponseFormatter<TOptions> Populate(Func<HttpExceptionDescriptor, MediaTypeHeaderValue, HttpContent> contentFactory, ICollection<HttpExceptionDescriptorResponseHandler> exceptionDescriptorHandlers = null)

Parameters

contentFactory Func<HttpExceptionDescriptor, MediaTypeHeaderValue, HttpContent>

The function delegate that will create an instance of HttpContent with input from the specified HttpExceptionDescriptor and MediaTypeHeaderValue.

exceptionDescriptorHandlers ICollection<HttpExceptionDescriptorResponseHandler>

The optional collection of HttpExceptionDescriptorResponseHandler instances to populate to.

Returns

HttpExceptionDescriptorResponseFormatter<TOptions>

A reference to this instance so that additional calls can be chained.

Exceptions

ArgumentNullException

contentFactory cannot be null.

See Also

Configurable<TOptions>
IHttpExceptionDescriptorResponseFormatter
Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware