Vapor Documentation Beta

Class Error​Middleware

public final class ErrorMiddleware: Middleware

Captures all errors and transforms them into an internal server error HTTP response.

%3 ErrorMiddleware ErrorMiddleware Middleware Middleware ErrorMiddleware->Middleware

Conforms To

Middleware

Middleware is placed between the server and your router. It is capable of mutating both incoming requests and outgoing responses. Middleware can choose to pass requests on to the next Middleware in a chain, or they can short circuit and return a custom Response if desired.

Initializers

init(_:​)

public init(_ closure: @escaping (Request, Error) -> (Response))

Create a new ErrorMiddleware.

Parameters

closure @escaping (Request, Error) -> (Response)

Error-handling closure. Converts Error to Response.

Methods

`default`(environment:​)

public static func `default`(environment: Environment) -> ErrorMiddleware

Create a default ErrorMiddleware. Logs errors to a Logger based on Environment and converts Error to Response based on conformance to AbortError and Debuggable.

Parameters

environment Environment

The environment to respect when presenting errors.

respond(to:​chaining​To:​)

public func respond(to request: Request, chainingTo next: Responder) -> EventLoopFuture<Response>

See Middleware.