refactor: Do not log error traces for 404 and 422 errors

This commit is contained in:
Faruk AYDIN
2025-05-22 15:22:52 +02:00
parent 0700b465de
commit bc0a8014ab

View File

@@ -19,19 +19,26 @@ import {
// eslint-disable-next-line no-unused-vars // eslint-disable-next-line no-unused-vars
const errorHandler = (error, request, response, next) => { const errorHandler = (error, request, response, next) => {
if (error.message === 'Not Found' || error instanceof NotFoundError) { if (error.message === 'Not Found' || error instanceof NotFoundError) {
logger.http(request.method + ' ' + request.url + ' ' + 404);
response.status(404).end(); response.status(404).end();
return;
} }
if (notFoundAppError(error)) { if (notFoundAppError(error)) {
logger.http(request.method + ' ' + request.url + ' ' + 404);
response.status(404).end(); response.status(404).end();
return;
} }
if (error instanceof ValidationError) { if (error instanceof ValidationError) {
logger.http(request.method + ' ' + request.url + ' ' + 422);
renderObjectionError(response, error, 422); renderObjectionError(response, error, 422);
return;
} }
if (error instanceof UniqueViolationError) { if (error instanceof UniqueViolationError) {
renderUniqueViolationError(response, error); renderUniqueViolationError(response, error);
return;
} }
if (error instanceof ForeignKeyViolationError) { if (error instanceof ForeignKeyViolationError) {