4.0.0 • Published 11 months ago
@mapbox/mapbox-error v4.0.0
@mapbox/mapbox-error
Generic error middleware for express.js apps.
usage
Install
npm i @mapbox/mapbox-error
Example application
import { showError, notFound, ErrorHTTP } from '@mapbox/mapbox-error';
import { express } from 'express';
const server = express();
// use ErrorHTTP to associate a status code and message to an Error object
server.get('/error', (req, res, next) => {
return next(new ErrorHTTP('Error for the sake of errors', 400));
});
// put these after all routes have been loaded
server.use(showError());
server.use(notFound());
You can create and re-use error classes
import { customErrorHTTP } from '@mapbox/mapbox-error';
const InvalidToken = customErrorHTTP('InvalidToken', 401);
// within an express middleware...
next(new InvalidToken());
develop
npm ci # install deps
npm run build # build project
npm test # run tests
npm run lint # lint
4.0.0-dev.1
11 months ago
4.0.0-dev.2
11 months ago
4.0.0-dev.3
11 months ago
4.0.0
11 months ago
3.1.0
3 years ago
3.0.3
3 years ago
3.0.2
4 years ago
3.1.0-dev3
5 years ago
3.1.0-dev2
5 years ago
4.0.0-dev2
5 years ago
4.0.0-dev
5 years ago
3.0.1
7 years ago
3.0.0
7 years ago
2.3.0-dev1
7 years ago