Skip to content

Commit be3f34a

Browse files
fix: Adjust logging in API middleware (#816)
1 parent ad2d28b commit be3f34a

File tree

2 files changed

+4
-9
lines changed

2 files changed

+4
-9
lines changed

src/API/Middlewares/HttpExceptionsMiddleware.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,10 @@ export const HttpExceptionsMiddleware: Koa.Middleware = async (context: any, nex
1414
context.status = 404
1515
} else {
1616
if (context.logger)
17-
context.logger.error({ exception }, 'Error Caught at Middleware')
17+
context.logger.error({ exception }, 'Error Caught at Middleware - Will Return Internal Server Error')
1818

19-
if (exception.expose) {
20-
context.body = exception.message || 'Internal Server Error'
21-
context.status = exception.status || 503
22-
} else {
23-
context.body = 'Internal Server Error'
24-
context.status = 503
25-
}
19+
context.body = 'Internal Server Error'
20+
context.status = 503
2621

2722
context.app.emit('error', exception, context)
2823
}

src/API/Router.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ export class Router {
111111
const files = context.request.files || {}
112112

113113
if (values(files).length <= 0)
114-
context.throw(422, 'No file found.')
114+
throw new IllegalArgumentException('No file found.')
115115

116116
const responses = await this.fileController.addFiles(map(createStreamFromFile, values(files)))
117117

0 commit comments

Comments
 (0)