-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
Remove try/catch for short url so the appropriate errors will be propagated to the UI #13004
Merged
stacey-gammon
merged 15 commits into
elastic:master
from
stacey-gammon:fix/show-short-url-errors
Jul 28, 2017
Merged
Changes from 9 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
b62b879
Remove try/catch for short url so the appropriate errors will be prop…
stacey-gammon 2295921
Simply ensure the error is a Boom error by wrapping it, but keep the …
stacey-gammon 5b90bc8
Merge branch 'master' of https://github.com/elastic/kibana into fix/s…
stacey-gammon b836eeb
Merge branch 'master' of https://github.com/elastic/kibana into fix/s…
stacey-gammon 3873b33
Merge branch 'master' of https://github.com/elastic/kibana into fix/s…
stacey-gammon a729049
Merge branch 'master' of https://github.com/elastic/kibana into fix/s…
stacey-gammon 716eea2
Merge branch 'master' of https://github.com/elastic/kibana into fix/s…
stacey-gammon d5f622f
Boom.wrap can't handle non Error instances, as exist in some of the t…
stacey-gammon 9cd4ce4
Merge branch 'master' of https://github.com/elastic/kibana into fix/s…
stacey-gammon 109a67f
Only support Error objects, and check both status and statusCode
stacey-gammon a7d36dc
fix test
stacey-gammon d4d7b15
Merge branch 'master' of https://github.com/elastic/kibana into fix/s…
stacey-gammon b7870ab
Fix test errors for reals this time
stacey-gammon 9f971e5
Merge branch 'master' of https://github.com/elastic/kibana into fix/s…
stacey-gammon a2e864e
Break out status and statusCode short url error tests
stacey-gammon File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,8 @@ | ||
import Boom from 'boom'; | ||
|
||
export function handleShortUrlError(err) { | ||
if (err.isBoom) return err; | ||
if (err.status === 401) return Boom.unauthorized(); | ||
if (err.status === 403) return Boom.forbidden(); | ||
if (err.status === 404) return Boom.notFound(); | ||
return Boom.badImplementation(); | ||
export function handleShortUrlError(error) { | ||
if (!error.isBoom && !(error instanceof Error)) { | ||
return Boom.create(error.status || 500); | ||
} | ||
return Boom.wrap(error, error.status || 500); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We really should not support non-errors here. Pretty sure this was spurred by the tests failing because they aren't sending real errors, which means that this code isn't actually testing what would happen in production with this condition. I think this check should go, we should always use
Boom.wrap()
and the tests should use real error objects.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.
I can do that, I was just worried about changing implementation details, not knowing if I would create a subtle bug somewhere.