-
-
Notifications
You must be signed in to change notification settings - Fork 31.4k
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
better display of errrors #24932
better display of errrors #24932
Conversation
Hello, and thanks for your contribution! I'm a bot set up to make sure that the project can legally accept this contribution by verifying everyone involved has signed the PSF contributor agreement (CLA). Recognized GitHub usernameWe couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames: This might be simply due to a missing "GitHub Name" entry in one's b.p.o account settings. This is necessary for legal reasons before we can look at this contribution. Please follow the steps outlined in the CPython devguide to rectify this issue. You can check yourself to see if the CLA has been received. Thanks again for the contribution, we look forward to reviewing it! |
"""Base class for other exceptions""" | ||
pass | ||
|
||
class ValueError(OurCustomError): |
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.
These classes are just going to confuse people: they have the same name as the builtin exception classes, but are different. Therefore code that tries to catch ValueError
will fail to catch pathlib.ValueError
except RuntimeError: | ||
print("Possible solutions please refer") | ||
print("For more information Refer /n https://stackoverflow.com/questions/58410380/laravel-to-python-runtimeerror-cant-determine-home-directory") | ||
print("Here the error you have encountered as program can't determine home directory") |
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.
- it's pretty pointless to raise an exception then immediately catch it 1 line later.
- The function now continues to run even after the error
- It's no longer possible for a caller to catch and handle the exceptions. Instead they get the printed error message output whatever they do, but no other indication that the function has failed
This PR is stale because it has been open for 30 days with no activity. |
To add to the comments from @da-woods, pathlib is a library and not an application. It is up to application code to decide how an exception should be handled. The pathlib library raises exceptions so that applications can decide how to handle them. In general, in order to make a change in the behaviour of python you don't jsut submit a patch, you need to at least create an issue on bpo where it can be discussed. You can also raise such suggestions on the python-ideas mailing list. Large changes require a PEP. |
Readable errors
created custom class for errors and displayed custom messages which are user friendly
works on file system which informs the user what error it encountered in a very basic understandable way in error code
This helps user to quickly figure out where is the mistake and aids in rectifying the mistake swiftly