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
Improve error related end-user experience #333
Draft
ftsell
wants to merge
15
commits into
master
Choose a base branch
from
feature/better_end_user_experience
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
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 makes it easier to determine what exactly went wrong and thus build better error handling in a later commit. Tests were adapted accordingly to assert that only those specific errors are raised instead of the plain ValueErrors.
Previously and ImproperlyConfigured error was always raised when an invalid default configured for the BooleanValue class. This behavior is unnecessary if the default is never used because the value is marked as environ_required. The check has thus been adapted to ignore invalid defaults in that case.
This introduces a function that wraps django entry points with an error handler so that our own exception can be pretty-printed to an end-user without a large stack-trace. The defined error handler has also been applied to the existing management, wsgi, asgi and fastcgi entry point definitions.
This way, multiple ConfigurationErrors are caught during setup, accumulated and printed all at once
Now Value classes accept a 'help_text' keyword which will get printed when a ValueRetrievalError or ValueProcessingError occurs
Now Value classes accept a 'help_reference' keyword which will get printed when a ValueRetrievalError or ValueProcessingError occurs
The test failed for two reasons. One was me changing the error string in a previous commit which I have adapted the test for now. The other was that django-cache-url changed its behavior. See #332
Codecov Report
@@ Coverage Diff @@
## master #333 +/- ##
==========================================
+ Coverage 89.94% 90.07% +0.12%
==========================================
Files 25 29 +4
Lines 1194 1360 +166
Branches 235 265 +30
==========================================
+ Hits 1074 1225 +151
- Misses 89 102 +13
- Partials 31 33 +2
Continue to review full report at Codecov.
|
Example generators are an addition to the 'Value' classes that allow the error handler to display example values for the failed value. For example if no django secret key is found to be defined in the environment, an example (secure) value for such a secret key can now be generated on the fly and be suggested to the user
ftsell
force-pushed
the
feature/better_end_user_experience
branch
from
March 24, 2022 13:44
fdfa41c
to
e57a9b8
Compare
ftsell
force-pushed
the
feature/better_end_user_experience
branch
from
March 24, 2022 13:57
e57a9b8
to
3b96d16
Compare
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.
In my opinion, an end-user who uses an application that was built using django-configurations should in most cases not see an unwieldy traceback, but instead a nicely formatted error detailing what went wrong and what they should do to rectify it.
In this regard, the PR is not aimed at application developers, but instead aims to improve the user experience of those end-users.
As an example, instead of a traceback, the user now receives something like this:
Additionally, this PR closes #332 because I was getting annoyed at the failing tests
This feature is implemented by introducing our own custom exception type that is raised during Value setup and processing and caught by our importer. When caught, an error handler pretty-prints the information that is included in the exception. This information is, in turn, automatically retrieved from the relevant Value.
THIS IS STILL A WORK IN PROGRESS because I still want to include more actionable information in the error message. Nonetheless, the PR gives others the opportunity to chime in about the feature.
TODOs:
ConfigurationError
s to display well-formatted errors to end-users, howhelp_text
,help_reference
andexample_generator
can be used