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

Question about error handling design in request functions #789

Open
L-cloud opened this issue Feb 26, 2025 · 0 comments
Open

Question about error handling design in request functions #789

L-cloud opened this issue Feb 26, 2025 · 0 comments

Comments

@L-cloud
Copy link

L-cloud commented Feb 26, 2025

Hello,

I'm a new user of this project and I've been trying to implement it in my own code. While working with it, I noticed a pattern in the error handling across request functions like _send_pycurl_request and _send_urllib_request that I'd like to understand better.

Both of these functions catch exceptions and return None in error cases:

# In _send_pycurl_request
except pycurl.error as err:
    LOGGER.error("pycurl error: %s %s", url, err)
    # ...
    return None
# In _send_urllib_request
except Exception as err:
    LOGGER.error("download error: %s %s", url, err)
    return None

This makes it challenging for calling code (like fetch_url and fetch_response) to determine:

  1. Whether an error occurred
  2. What type of error occurred
  3. How to handle specific error cases

I'm wondering if there's a specific design reason for returning None instead of raising exceptions or returning a more informative error response? Are there plans to enhance the error handling approach in future versions?

I understand there might be good architectural reasons for this design that I'm missing as a new user, so I appreciate any insight you can provide.

Thank you!

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