Skip to content
This repository has been archived by the owner on Apr 20, 2024. It is now read-only.

ml-archive/error-extended

Repository files navigation

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