Skip to content

enbermudas/fail-express

Repository files navigation

fail-express

npm version Build Status Coverage Status

Fail-express is an express error-handler middleware for JSON APIs. This library uses http-status.

Example

const express = require('express');
const failExpress = require('fail-express');

const app = new express();
const router = express().Router();

router.get('/status', (req, res, next) => {
  res.send('Online!');
});

app.use('/api/v1', router);

router.use(failExpress());

API

const failExpress = require('fail-express');

failExpress([options]);

Use the new fail-express middleware function using the given options.

Options

fail-express accepts this properties in the options object.

errorReporter

Function that receives the error object with its default properties. Default fail-express error reporter:

const defaultErrorReporter = error => {
  console.error(error.stack);
};
displayStackTrace

Appends the error stack trace to the error object.

exposeAdditionalProperties

Appends additional properties to the error object.

Errors

Default properties:

  • message
  • type
  • name
  • code
  • status

License

MIT

About

Fail-express is an express error-handler middleware for JSON APIs

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published