-
Notifications
You must be signed in to change notification settings - Fork 115
Closed
Description
I am sorry if I had written rude things because I am poor at English.
When I specified Error
as the second argument, there was a key like status
or statusCode
, so the status code of the first argument was overwritten.
Error is like this.
{ MessageRejected: Email address is not verified.....
message: 'Rejected',
code: 'ClientError',
statusCode: 400}
And, I written the following code.
try {
....
} catch (e) {
throw createError(500, e, { errors: [{ msg: 'sending mail was failed' }] })
}
In the case of the above error, the first argument is ignored and the return value of status is forced to 400.
And I return the status of the Error to the client, as the status code of the response.
This is caused by the following code.
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i]
if (arg instanceof Error) {
err = arg
status = err.status || err.statusCode || status
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I think it's strange that status
was changed by the first argument , but it will changed again.
Metadata
Metadata
Assignees
Labels
No labels