-
Notifications
You must be signed in to change notification settings - Fork 982
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: adds support to http problem details - rfc7807 #1786
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,3 +14,4 @@ deps/javascriptlint | |
deps/jsstyle | ||
package-lock.json | ||
benchmark/results | ||
.idea |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1435,7 +1435,7 @@ Server.prototype._routeErrorResponse = function _routeErrorResponse( | |
} | ||
|
||
// only automatically send errors that are known (e.g., restify-errors) | ||
if (err instanceof Error && _.isNumber(err.statusCode)) { | ||
if (err instanceof Error && _.isNumber(err.statusCode || err.status)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. when is this There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. exactly, and This PR keeps There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. class NotFound extends Error {
constructor(detail) {
this.title = 'Not Found';
this.type = 'https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/404';
this.status = 404;
this.detail = detail || 'Resource not found';
}
toJSON() {
return this;
}
} this will conform with rfc7807 and will hit that code with There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You know what? It doesn't really need to "have a status property instead of a statusCode" to conform to the rfc. I was mainly using But we can have a |
||
res.send(err); | ||
return; | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when is this
status
?