mirror of
https://github.com/linux-odyssey/linux-odyssey.git
synced 2026-11-05 19:20:12 +08:00
14 lines
393 B
JavaScript
14 lines
393 B
JavaScript
import logger from '../utils/logger.js'
|
|
|
|
export function asyncHandler(fn) {
|
|
return (req, res, next) => {
|
|
fn(req, res, next).catch(next)
|
|
}
|
|
}
|
|
|
|
// eslint-disable-next-line no-unused-vars
|
|
export default function errorHandler(err, req, res, next) {
|
|
logger.error(err) // Log error stack trace to the console
|
|
res.status(500).send({ message: 'Something broke!' }) // Send error response
|
|
}
|