Class ErrorOptions
error response customization settings
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public sealed class ErrorOptions
Properties
GeneralErrorsField
the general errors field name. this is the field name used for general errors when AddError() method is called without specifying a request dto property.
Declaration
public string GeneralErrorsField { set; }
Property Value
Type | Description |
---|---|
string |
ProducesMetadataType
if this property is not null, a IProducesResponseTypeMetadata will automatically be added to endpoints that has a Validator<TRequest> associated with it. if you're specifying your own ResponseBuilder, don't forget to set this property to the correct type of the error response dto that your error response builder will be returning.
TIP: set this to null if you'd like to disable the auto adding of produces 400 metadata to endpoints even if they have validators associated with them.
Declaration
public Type? ProducesMetadataType { set; }
Property Value
Type | Description |
---|---|
Type |
ResponseBuilder
a function for transforming validation errors to an error response dto. set it to any func that returns an object that can be serialized to json. this function will be run everytime an error response needs to be sent to the client. the arguments for the func will be a list of validation failures, the http context and an http status code.
HINT: if changing the default, make sure to also set ProducesMetadataType to the correct type of the error response dto.
Declaration
public Func<List<ValidationFailure>, HttpContext, int, object> ResponseBuilder { set; }
Property Value
Type | Description |
---|---|
Func<List<ValidationFailure>, HttpContext, int, object> |
StatusCode
this http status code will be used for all automatically sent validation failure responses. defaults to 400.
Declaration
public int StatusCode { set; }
Property Value
Type | Description |
---|---|
int |
Methods
UseProblemDetails()
change the default error response builder to ProblemDetails instead of ErrorResponse
Declaration
public void UseProblemDetails()