Skip to content

Commit c9c9b4d

Browse files
committed
Handling 404
1 parent 80b0306 commit c9c9b4d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

docker-compose.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ services:
44
container_name: nodejsmongoosees8restapi
55
build: .
66
ports:
7-
- "4000:8081"
7+
- "5000:5000"
88
depends_on:
99
- mongodb
1010
environment:

server/config/errorHandler.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,10 @@ const log = debug('app')
1010
const errorHandler = (err, req, res, next) => {
1111
log(err)
1212

13-
if (err.name === 'UnauthorizedError') return res.status(httpStatus.UNAUTHORIZED).send({ error: err.message })
14-
1513
if (err instanceof AppError) return res.status(err.status).json({ error: err.message, stack: process.env.APP_ENVIROMENT === 'dev' ? err.stack : '' })
1614

15+
if (err.name === 'UnauthorizedError') return res.status(httpStatus.UNAUTHORIZED).json({ error: err.message })
16+
1717
return res.status(httpStatus.INTERNAL_SERVER_ERROR).json({ error: process.env.APP_ENVIROMENT === 'dev' ? err.message : 'Oops !! Something went wrong' })
1818
}
1919

0 commit comments

Comments
 (0)