-
-
Notifications
You must be signed in to change notification settings - Fork 771
Description
Hey folks, first off, awesome library!
I'm opening this issue to suggest a documentation improvement. I think it would be super helpful for new users to have a dedicated page on resty.dev (and maybe linked in the README) that's all about error handling.
For a beginner, it can be pretty confusing to figure out the difference between the two main ways an error can happen.
-
The
errreturned from the request:res, err := client.R().Get("https://example.com") if err != nil { // What kind of error is this? (e.g., connection failed, DNS, timeout) }
-
The
res.IsError()check:if res.IsError() { // And what kind of error is this? (e.g., 404, 500) }
A new user might see err == nil and assume everything worked, but they might have actually received a 500 Internal Server Error. Or, they might get a connection error where err != nil, and then try to check res.IsError()
Having a "Error Handling" page would be amazing. It could clearly explain:
- When
errwill be non-nil (client-side problems, connection issues, timeouts, marshalling errors, etc.). - When
res.IsError()will be true (server-side problems, 4xx/5xx status codes). - The recommended "best practice" way to check for both conditions to safely handle all possible errors.
- Basically, a guide for everything related to errors
I think this would clear up a lot of confusion and help people get started more smoothly.
Thanks for considering it!