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
Object
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

System.ArgumentNullException

options cannot be null.

System.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 Microsoft.Extensions.Options.IOptions<TOptions> which need to be configured.

Exceptions

System.ArgumentNullException

options cannot be null.

System.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 System.Action<T> which need to be configured.

Exceptions

System.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 Microsoft.Extensions.Options.Options to your liking.

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

Parameters

setup Action<TOptions>

The System.Action<T> which need to be configured.

Returns

HttpExceptionDescriptorResponseFormatter<TOptions>

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

Exceptions

System.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 System.Net.Http.HttpContent with input from the specified HttpExceptionDescriptor and System.Net.Http.Headers.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

System.ArgumentNullException

contentFactory cannot be null.

See Also

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