ErrorExtended
Vapor errors with more granularity.
π¦ Installation
Update your Package.swift
file.
.Package(url: "https://github.com/nodes-vapor/error-extended.git", majorVersion: 1)
Getting started π
import ErrorExtended
If you need more granular control on the content that goes into your errors conforming to the AbortError
protocol you can use the AbortExtended
type instead (which conforms to AbortError
). This type will give you access to all of the parameters as well as providing you with some convenient extra parameters.
A couple of examples:
throw AbortExtended.custom(code: 1337)
throw AbortExtended.custom(
status: .badRequest,
code: 1337,
message: "Sorry, bad request",
report: false
)
throw AbortExtended.custom(
status: .badGateway,
code: Status.badGateway.statusCode,
message: Status.badGateway.reasonPhrase,
metadata: Node(["key": "value"]),
report: false
)
Any middleware (e.g. bugsnag) that tries to catch errors conforming to AbortError
will then pick this up.
π Credits
This package is developed and maintained by the Vapor team at Nodes. The package owner for this project is Rasmus.
π License
This package is open-sourced software licensed under the MIT license