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

Add request method and URL to error messages #595

Merged
merged 1 commit into from
Jun 24, 2024

Conversation

sholladay
Copy link
Collaborator

Closes #592

This PR aims to make the error messages from Ky's TimeoutError and HTTPError more helpful by including the request method and URL.

Before:

TimeoutError: Request timed out
HTTPError: Request failed with status code 400 Bad Request

After:

TimeoutError: Request timed out: POST https://localhost:3000/
HTTPError: Request failed with status code 400 Bad Request: POST https://localhost:3000/

@arty-name
Copy link
Contributor

I guess, too long URLs are not a real concern here

@sholladay
Copy link
Collaborator Author

The maximum length of a valid URL is around 2000 characters. Which is indeed long, but still short enough that I would expect most logging systems to handle it.

https://stackoverflow.com/questions/417142/what-is-the-maximum-length-of-a-url-in-different-browsers

We could truncate the URL to protect against invalid URLs or in the interest of readability, but that definitely makes the log entry less useful. I’m inclined to report the URL as-is.

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.

Set TimeoutError#cause to be Request or URL
2 participants