huridocs/uwazi

View on GitHub
app/api/utils/error_handling_middleware.js

Summary

Maintainability
A
0 mins
Test Coverage
A
100%
import { handleError } from './handleError';

export default (error, req, res, next) => {
  const { message, code, ...rest } = handleError(error, { req });

  res.status(code);
  res.json({ error: message, ...rest });

  next();
};