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

Try Except clause prints that all exceptions are 404s not their correct exception type. #12

Open
prrifth opened this issue Jun 23, 2024 · 0 comments

Comments

@prrifth
Copy link

prrifth commented Jun 23, 2024

In crawler.py, there's this code:

try:
	response = urllib.request.urlopen(url)

except:
	print('404 error')
	return

However, 404 is not the only possible exception that can occur with urllib.request.urlopen().

Solution:

try:
	response = urllib.request.urlopen(url)

except Exception:
	print(repr(Exception))
	return

This prints the correct exception message and avoids user confusion, as in the case of the closed issue about 404 errors for sites that exist, which can be due to other errors, such as an SSL certificate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant