error utils
npm install @blocklet/error@blocklet/error provides utils for error handling.
``shell`
npm install @blocklet/error
`ts
const { CustomError, formatError, getStatusFromError } = require('@blocklet/error');
// throw error
const err = new CustomError(400, 'test error');
throw err;
// get status from error
app.use((err, req, res, next) => {
const status = getStatusFromError(err);
res.status(status).json({ error: formatError(err) });
});
``