import {Request, Response, NextFunction} from "express";

module.exports = ((err: Error | undefined, req: Request, res: Response, next: NextFunction) => {
    if (err instanceof SyntaxError) {
        return res.status(500).send({ message: err.message });
    } else if (err) {
        return res.status(500).json({message: "An internal error occurred"});
    }
    next();
});