Vapor Documentation Beta

Protocol Abort​Error

public protocol AbortError: Error

Errors conforming to this protocol will always be displayed by Vapor to the end-user (even in production mode where most errors are silenced).

extension MyError: AbortError { ... }
throw MyError(...) // Can now result in non-500 error.

See Abort for a default implementation of this protocol.

throw Abort(.badRequest, reason: "Something's not quite right...")
%3 AbortError AbortError Error Error AbortError->Error ValidationsError ValidationsError ValidationsError->AbortError Abort Abort Abort->AbortError

Conforms To

Error

Types Conforming to Abort​Error

Abort

Default implementation of AbortError. You can use this as a convenient method for throwing AbortErrors without having to conform your own error-type to AbortError.

ValidationsError

Requirements

reason

var reason: String

The reason for this error.

status

var status: HTTPResponseStatus

The HTTP status code this error will return.

headers

var headers: HTTPHeaders

Optional HTTPHeaders to add to the error response.