chore: Extract error handler and graphql instance to seperate files
This commit is contained in:
13
packages/backend/src/helpers/error-handler.ts
Normal file
13
packages/backend/src/helpers/error-handler.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
import { Request, Response, NextFunction } from 'express';
|
||||
import logger from './logger';
|
||||
|
||||
const errorHandler = (err: any, req: Request, res: Response, _next: NextFunction) => {
|
||||
if(err.message === 'Not Found') {
|
||||
res.status(404).end()
|
||||
} else {
|
||||
logger.error(err.message)
|
||||
res.status(500).end()
|
||||
}
|
||||
}
|
||||
|
||||
export default errorHandler;
|
Reference in New Issue
Block a user