-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove try/catch for short url so the appropriate errors will be prop…
…agated to the UI (#13004) (#13179) * Remove try/catch for short url so the appropriate errors will be propagated to the UI * Simply ensure the error is a Boom error by wrapping it, but keep the original error details. * Boom.wrap can't handle non Error instances, as exist in some of the tests. * Only support Error objects, and check both status and statusCode * fix test * Fix test errors for reals this time * Break out status and statusCode short url error tests
- Loading branch information
1 parent
67de869
commit 17dc4e6
Showing
3 changed files
with
43 additions
and
29 deletions.
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
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,5 @@ | ||
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) { | ||
return Boom.wrap(error, error.statusCode || 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