Class ErrorResponse
the dto used to send an error response to the client
Inherited Members
Namespace: FastEndpoints
Assembly: FastEndpoints.dll
Syntax
public sealed class ErrorResponse : IResult, IEndpointMetadataProvider
Constructors
ErrorResponse()
instantiate a new error response without any errors
Declaration
public ErrorResponse()
ErrorResponse(List<ValidationFailure>, int)
instantiate an error response with the given collection validation failures
Declaration
public ErrorResponse(List<ValidationFailure> failures, int statusCode = 400)
Parameters
Type | Name | Description |
---|---|---|
List<ValidationFailure> | failures | validation failures to initialize the DTO with |
int | statusCode |
Properties
Errors
the collection of errors for the current context
Declaration
public Dictionary<string, List<string>> Errors { get; set; }
Property Value
Type | Description |
---|---|
Dictionary<string, List<string>> |
Message
the message for the error response
Declaration
public string Message { get; set; }
Property Value
Type | Description |
---|---|
string |
StatusCode
the http status code sent to the client. default is 400.
Declaration
public int StatusCode { get; set; }
Property Value
Type | Description |
---|---|
int |
Methods
ExecuteAsync(HttpContext)
Write an HTTP response reflecting the result.
Declaration
public Task ExecuteAsync(HttpContext httpContext)
Parameters
Type | Name | Description |
---|---|---|
HttpContext | httpContext | The HttpContext for the current request. |
Returns
Type | Description |
---|---|
Task | A task that represents the asynchronous execute operation. |
PopulateMetadata(MethodInfo, EndpointBuilder)
Populates metadata for the related Endpoint and MethodInfo.
Declaration
public static void PopulateMetadata(MethodInfo _, EndpointBuilder builder)
Parameters
Type | Name | Description |
---|---|---|
MethodInfo | _ | |
EndpointBuilder | builder | The EndpointBuilder used to construct the endpoint for the given |
Remarks
This method is called by RequestDelegateFactory when creating a RequestDelegate and by MVC when creating endpoints for controller actions.
This is called for each parameter and return type of the route handler or action with a declared type implementing this interface.
Add or remove objects on the Metadata property of the builder
to modify the Metadata being built.