nodes-vapor / error-extended

Vapor errors with more granularity.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ErrorExtended

Swift Version Vapor Version Circle CI codebeat badge codecov Readme Score GitHub license

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

About

Vapor errors with more granularity.

License:MIT License


Languages

Language:Swift 100.0%