Skip to content

Commit 163dfbe

Browse files
committed
fix(renault): improve handling of status errors in provider
1 parent 665cc0a commit 163dfbe

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

vehicle/renault/provider.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,8 @@ func (v *Provider) GetLimitSoc() (int64, error) {
137137
res, err := v.socLevelsG()
138138

139139
// Check if endpoint is unavailable
140-
if se := new(request.StatusError); errors.As(err, &se) && se.HasStatus(http.StatusForbidden, http.StatusNotFound, http.StatusBadGateway) {
140+
var se *request.StatusError
141+
if errors.As(err, &se) && se.HasStatus(http.StatusForbidden, http.StatusNotFound, http.StatusBadGateway) {
141142
return 0, api.ErrNotAvailable
142143
}
143144

@@ -178,7 +179,8 @@ func (v *Provider) Climater() (bool, error) {
178179
res, err := v.hvacG()
179180

180181
// Zoe Ph2, Megane e-tech
181-
if se := new(request.StatusError); errors.As(err, &se) && se.HasStatus(http.StatusForbidden, http.StatusNotFound, http.StatusBadGateway) {
182+
var se *request.StatusError
183+
if errors.As(err, &se) && se.HasStatus(http.StatusForbidden, http.StatusNotFound, http.StatusBadGateway) {
182184
return false, api.ErrNotAvailable
183185
}
184186

0 commit comments

Comments
 (0)