Closed vforv closed 7 years ago
This is the expected behavior. If you return an error in Hapi the default error code is 500. You can set it with reply(err).code(400)
(404 bad request)
createUser(req: HapiRequest, reply: Hapi.ReplyNoContinue) {
let user: UserCreateInterface = req.payload;
return req.hemera.act({ topic: 'user-save', type: 'amerbank', payload: user },
function (err: any, result: any) {
if (err) {
if (err.name === 'PreValidationError') {
return reply({ success: false, message: err.message }).code(404)
} else {
return reply(err)
}
}
reply(result)
})
}
In the next release it is possible to compare the errors with instanceof
this is cleaner
Thanks, I make it works with boom.
On api side where is hemera hapi I have basic act request:
here is add in service:
In logs I get error messaga:
But api returns: Internal server error