Search Results for

    Show / Hide Table of Contents

    Class ErrorOptions

    error response customization settings

    Inheritance
    object
    ErrorOptions
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.ReferenceEquals(object, object)
    object.ToString()
    Namespace: FastEndpoints
    Assembly: FastEndpoints.dll
    Syntax
    public sealed class ErrorOptions

    Properties

    ContentType

    the content-type header value for 400 error responses

    Declaration
    public string ContentType { set; }
    Property Value
    Type Description
    string

    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 a 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(Action<ProblemDetailsConfig>?)

    change the default error response builder to ProblemDetails instead of ErrorResponse

    Declaration
    public void UseProblemDetails(Action<ErrorOptions.ProblemDetailsConfig>? config = null)
    Parameters
    Type Name Description
    Action<ErrorOptions.ProblemDetailsConfig> config

    an action for configuring global settings for ProblemDetails

    In this article
    Back to top Developed by Đĵ ΝιΓΞΗΛψΚ and contributors / Licensed under MIT / Website generated by DocFX