Skip to content

Ensure status param takes precedence over error.status - #38

Closed
jasonkarns wants to merge 1 commit into
jshttp:masterfrom
jasonkarns:status-param-over-error
Closed

Ensure status param takes precedence over error.status#38
jasonkarns wants to merge 1 commit into
jshttp:masterfrom
jasonkarns:status-param-over-error

Conversation

@jasonkarns

Copy link
Copy Markdown

I believe this is a bug.

Prior to this change:

_err=newError()_err.status=404err=createError(500,_err)// err.status == 404

After this change (no tests modified):

_err=newError()_err.status=404err=createError(500,_err)// err.status == 500

@dougwilson

Copy link
Copy Markdown
Contributor

Imo it is not a bug, orgerwide if you wrap an error from thos module with a different code, the error name and other props will not reflect correctly.

@dougwilson

Copy link
Copy Markdown
Contributor

I.e. you can end up with err instanceof NotFoundError but err.statusCode === 410 witch is not desired.

@jasonkarns

Copy link
Copy Markdown
Author

Closing as works-as-designed.

#37 now includes a new test to actually verify/document this behavior as intended. 91a7445#diff-c1129c8b045390789fa8ff62f2c6b4a9R180

@jasonkarns
jasonkarns deleted the status-param-over-error branch September 8, 2017 14:13
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jasonkarns@dougwilson