Ekspres penanganan kesalahan naskah

import express, { NextFunction, ErrorRequestHandler } from 'express'

const app = express()
app.use(<ErrorRequestHandler>function(err, req, res, next: NextFunction) {
  res.status(err.status ?? 500)
  res.json({
    success: false,
    error: 'Internal error occured'
  })
  next(err)
})
Frustrated Developer