Commit 4dc83e80 authored by Agustin Ruiz Diaz Cambon's avatar Agustin Ruiz Diaz Cambon
Browse files

ValidationError message fix(should be refactored)

parent e3a21426
Pipeline #15997 passed with stage
in 1 minute and 44 seconds
......@@ -44,7 +44,13 @@ app.use((error: Error, request: Request, response: Response, next: NextFunction)
// Check the error is a validation error
if (error instanceof ValidationError) {
// TODO: Handle error message accordingly
response.status(400).send(error.validationErrors.body);
let msg: string | undefined;
if (error.validationErrors.body && error.validationErrors.body[0]) {
msg = error.validationErrors.body[0].message;
}
if (msg) {
response.status(400).send(msg);
}
next();
} else {
// Pass error on if not a validation error
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment