curl-to-go icon indicating copy to clipboard operation
curl-to-go copied to clipboard

Add checks for http status code

Open mhewedy opened this issue 3 years ago • 2 comments

I think it is better to add in the generated sample code a check (even if commented) for HTTP status code (just as a hint). example:

if resp.StatusCode != http.StatusOK {
	// handle status code not 200
}

BTW, I spent long time not sure what is the error until I realized at the end that, the status code check is not there 😄

mhewedy avatar Dec 12 '21 10:12 mhewedy

Maybe if resp.StatusCode >= 400 is more suitable. But yeah, that's a reasonable idea.

mholt avatar Dec 13 '21 19:12 mholt

at end of the day, it is a hint for the developer that not to forget such checks

mhewedy avatar Dec 13 '21 19:12 mhewedy