Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Julieta Dubra Raimunde
repp_backend
Commits
4dc83e80
Commit
4dc83e80
authored
Oct 14, 2021
by
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
Changes
1
Pipelines
2
Hide whitespace changes
Inline
Side-by-side
src/index.ts
View file @
4dc83e80
...
...
@@ -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
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment