Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
xsalonx committed Mar 6, 2024
1 parent 1672658 commit 73ee5dc
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/server/express/updateExpressResponseFromNativeError.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* or submit itself to any jurisdiction.
*/

const { ConflictError } = require('../errors/ConflictError.js');
const { NotFoundError } = require('../errors/NotFoundError.js');

/**
Expand All @@ -32,6 +33,11 @@ const updateExpressResponseFromNativeError = (response, error) => {
title = 'Not found';
}

if (error instanceof ConflictError) {
status = 409;
title = 'Conflict in data';
}

response.status(status).json({ errors: [{ status, title, detail: message || 'An error has occurred' }] });
};

Expand Down

0 comments on commit 73ee5dc

Please sign in to comment.