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

Unhandled exception when checking if URL exists #101 #102

Closed
wants to merge 2 commits into from

Conversation

BansheeHero
Copy link

Handle exceptions raised from the use of requests.exceptions.
Implement warning and critical in the style of the original authors:
Warning is used for capturing the faulty request.
Critical is used to notify user that there is a problem.

I am still leaving the raise FileNotFoundError there as I wanted to make another request for turning this optional.

Handle exceptions raised from the use of `requests.exceptions`.
Default value is False.
Moved raising the exception behind the parameter.
@fralau fralau added the please open issue A PR was created without the issue being discussed. label Jun 3, 2024
@fralau
Copy link
Owner

fralau commented Jun 3, 2024

Please relate this PR to an existing issue, or open one.

@BansheeHero
Copy link
Author

BansheeHero commented Jun 3, 2024

Please relate this PR to an existing issue, or open one.

There should be one open already: #101.

@fralau fralau linked an issue Jun 3, 2024 that may be closed by this pull request
@fralau
Copy link
Owner

fralau commented Jun 3, 2024

The best way to make the link is to indicate, on the right of the pane under "Development", the number of the issue. I did that.

Capture d’écran 2024-06-03 à 16 23 37

@fralau fralau removed the please open issue A PR was created without the issue being discussed. label Jul 29, 2024
try:
request = requests.get(url)
except Exception as ue:
if ue.__class__.__module__ == "requests.exceptions":
Copy link

@EvaSDK EvaSDK Aug 16, 2024

Choose a reason for hiding this comment

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

Just catch the exception you want to handle separately direclty.

try:
    res = requests.get(url)
except requests.exceptions.RequestException:
    warning("Exception when making a GET request: %s" % ue)
    return False
else:
    return request.status_code == 200

Copy link

Choose a reason for hiding this comment

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

Hum, but this does not cover all exceptions so nevermind.

@fralau
Copy link
Owner

fralau commented Sep 5, 2024

Replaced by commit 2fb1038 (see #101 )

@fralau fralau closed this Sep 5, 2024
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

Successfully merging this pull request may close these issues.

Unhandled exception when checking if URL exists
4 participants