mirror of
https://github.com/coder/coder.git
synced 2025-07-03 16:13:58 +00:00
fix: return a more sophisticated error for device failure on 429 (#11554)
* fix: return a more sophisticated error for device failure on 429
This commit is contained in:
@ -321,7 +321,14 @@ func (c *DeviceAuth) AuthorizeDevice(ctx context.Context) (*codersdk.ExternalAut
|
||||
}
|
||||
err = json.NewDecoder(resp.Body).Decode(&r)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
// Some status codes do not return json payloads, and we should
|
||||
// return a better error.
|
||||
switch resp.StatusCode {
|
||||
case http.StatusTooManyRequests:
|
||||
return nil, fmt.Errorf("rate limit hit, unable to authorize device. please try again later")
|
||||
default:
|
||||
return nil, err
|
||||
}
|
||||
}
|
||||
if r.ErrorDescription != "" {
|
||||
return nil, xerrors.New(r.ErrorDescription)
|
||||
|
Reference in New Issue
Block a user