Feature: Add rawError option#44
Closed
rafoss wants to merge 2 commits intoUpstatement:mainfrom
rafoss:feature/add-option-rawError
Closed
Feature: Add rawError option#44rafoss wants to merge 2 commits intoUpstatement:mainfrom rafoss:feature/add-option-rawError
rawError option#44rafoss wants to merge 2 commits intoUpstatement:mainfrom
rafoss:feature/add-option-rawError
Conversation
Contributor
|
Hey @rafoss! Thank you so much for submitting this PR (and apologies for taking so long to review it)! We agree with your sentiment of replacing the default Thank you again for your contributions! 🙌 |
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
Introduces a new boolean option
rawErrortoGuardProviderandGuardedRoutewhich makes them pass through errors thrown byGuardFunctionsunaltered.What this does
It alters the behaviour of error handling as seen here to use the raw thrown value instead of trying to access the
messageproperty on it and returning"Not found."as a fallback.Use case
Custom errors such as extended Error objects which specify further details or entirely custom types thrown by
GuardFunctionscan now be accessed on theerrorprop of the Error page component.A
GuardFunctioncould for instancethrow 403;to indicate HTTP status code403 Forbiddento the Error page so it can conditionally render a forbidden page. This way it's not necessary to supply differenterrorprops perGuardedRouteyou want to display different errors for.Sidenote
In my opinion, a breaking change to supply the raw error by default would be nicer, but may cause more problems than it solves, so I've submitted this PR as a backwards compatible solution.
How to test
No test changes were made.