Skip to content
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

Closed
wants to merge 1 commit into from
Closed

Conversation

Joshan90
Copy link

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

@the-knights-who-say-ni
Copy link

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 username

We couldn't find a bugs.python.org (b.p.o) account corresponding to the following GitHub usernames:

@Joshan90

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):
Copy link
Contributor

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")
Copy link
Contributor

@da-woods da-woods Mar 19, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. it's pretty pointless to raise an exception then immediately catch it 1 line later.
  2. The function now continues to run even after the error
  3. 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

@github-actions
Copy link

This PR is stale because it has been open for 30 days with no activity.

@github-actions github-actions bot added the stale Stale PR or inactive for long period of time. label Apr 20, 2021
@iritkatriel
Copy link
Member

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review stale Stale PR or inactive for long period of time.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants