AbortError

public protocol AbortError : Debuggable

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...")
  • The HTTP status code this error will return.

    Declaration

    Swift

    var status: HTTPResponseStatus { get }
  • headers Default implementation

    Optional HTTPHeaders to add to the error response.

    Default Implementation

    See AbortError.

    Declaration

    Swift

    var headers: HTTPHeaders { get }
  • The human-readable (and hopefully understandable) reason for this error.

    Declaration

    Swift

    var reason: String { get }