mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-17 08:50:15 +01:00
chore: improve meili error handling
This commit is contained in:
parent
68979015c1
commit
655e7ce6d6
9 changed files with 182 additions and 64 deletions
|
|
@ -3,11 +3,13 @@ const handleDuplicateKeyError = (err, res) => {
|
|||
const field = Object.keys(err.keyValue);
|
||||
const code = 409;
|
||||
const error = `An document with that ${field} already exists.`;
|
||||
console.log('congrats you hit the duped keys error');
|
||||
res.status(code).send({ messages: error, fields: field });
|
||||
};
|
||||
|
||||
//handle validation errors
|
||||
const handleValidationError = (err, res) => {
|
||||
console.log('congrats you hit the validation middleware');
|
||||
let errors = Object.values(err.errors).map(el => el.message);
|
||||
let fields = Object.values(err.errors).map(el => el.path);
|
||||
let code = 400;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue