wf-radio/src/middleware/errors.js
Gu://em_ 306c87fca2 feat: Error handling middleware
feat: Ability to get the db variable from everywhere with getDatabase function
feat: Hello world when getting root url
fix: Now mods model is able to communicate with db
fix: fixed a syntax error in routes/mods.js file which caused sending two responses to the client
2025-03-29 00:31:25 +01:00

19 lines
426 B
JavaScript

const AppError = require("../utils/AppError");
const handleError = (err, req, res, next) => {
// Send
if (err instanceof AppError) {
return res.status(err.statusCode).json({
message: err.message,
status: err.status
});
}
// Default error
res.status(500).json({
message: 'Internal server error',
status: 500
});
}
module.exports = handleError;