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