Fix missing status code for ErrorResponse

This commit is contained in:
Jesús Ángel 2019-01-30 17:42:35 +01:00
parent 64c32b326d
commit 352d06e10f

View File

@ -28,7 +28,8 @@
export function ErrorResponse(
message = null,
code = null,
statusCode = null
statusCode = null,
h
) {
let filteredMessage = '';
if (code) {
@ -65,13 +66,13 @@ export function ErrorResponse(
}
}
return {
return h.response({
message: filteredMessage
? `${code ? code : 1000} - ${filteredMessage}`
? `${code || 1000} - ${filteredMessage}`
: typeof message === 'string'
? `${code ? code : 1000} - ${message}`
: `${code ? code : 1000} - Unexpected error`,
code: code ? code : 1000,
statusCode: statusCode ? statusCode : 500
};
? `${code || 1000} - ${message}`
: `${code || 1000} - Unexpected error`,
code: code || 1000,
statusCode: statusCode || 500
}).code(statusCode || 500);
}