Silence01: request retry on HTTP 500

This commit is contained in:
andig 2022-07-29 10:57:57 +02:00
parent 3597047272
commit c15e8b9782

View file

@ -2,7 +2,9 @@ package silence
import (
"errors"
"net/http"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
"github.com/samber/lo"
@ -45,6 +47,11 @@ func (v *API) Vehicles() ([]string, error) {
}), nil
}
// force retry on HTTP 500
if err2, ok := err.(request.StatusError); ok && err2.HasStatus(http.StatusInternalServerError) {
err = api.ErrMustRetry
}
return nil, err
}