2.0.0 • Published 6 years ago
express-error-slack v2.0.0
express-error-slack
Express error handling middleware for reporting error to Slack
Install
$ npm install --save express-error-slackUsage
const express = require('express')
const errorToSlack = require('express-error-slack')
const app = express()
// Route that triggers a error
app.get('/error', function (req, res, next) {
const err = new Error('Internal Server Error')
err.status = 500
next(err)
})
// Send error reporting to Slack
app.use(errorToSlack({ webhookUri: 'https://hooks.slack.com/services/TOKEN' }))
app.listen(3000)API
const errorToSlack = require('express-error-slack')errorToSlack(options)
Create a error handling middleware to send error reporting to Slack channel.
Options
{
webhookUri: String,
skip: function (err, req, res) { return false },
debug: Boolean
}webhookUri: Required. Your Slack webhook uri that the channel will receive error reporting.skip: Optional. A function to determine if handler is skipped. Defaults to always returningfalse.debug: Optional. Show logging of response from Slack if set true. Defaults tofalse.
Result Example
4xx

5xx

License
MIT © Chun-Kai Wang