Improve sponsor message

This commit is contained in:
andig 2021-08-12 21:55:55 +02:00
parent d5262f4b42
commit 0da5c6ce91
5 changed files with 7 additions and 7 deletions

View file

@ -8,6 +8,9 @@ var ErrNotAvailable = errors.New("not available")
// ErrMustRetry indicates that a rate-limited operation should be retried
var ErrMustRetry = errors.New("must retry")
// ErrSponsorRequired indicates that a sponsor token is required
var ErrSponsorRequired = errors.New("sponsorship required, see https://github.com/andig/evcc#sponsorship")
// ErrTimeout is the error returned when a timeout happened.
// Modeled after context.DeadlineError
var ErrTimeout error = errTimeoutError{}

View file

@ -2,7 +2,6 @@ package charger
import (
"encoding/binary"
"errors"
"fmt"
"github.com/andig/evcc/api"
@ -59,7 +58,7 @@ func NewABLeMH(uri, device, comset string, baudrate int, slaveID uint8) (api.Cha
}
if !sponsor.IsAuthorized() {
return nil, errors.New("abl requires evcc sponsorship, register at https://cloud.evcc.io")
return nil, api.ErrSponsorRequired
}
log := util.NewLogger("abl")

View file

@ -1,7 +1,6 @@
package charger
import (
"errors"
"fmt"
"net/http"
"time"
@ -58,7 +57,7 @@ func NewEasee(user, password, charger string, circuit int, cache time.Duration)
log := util.NewLogger("easee")
if !sponsor.IsAuthorized() {
return nil, errors.New("easee requires evcc sponsorship, register at https://cloud.evcc.io")
return nil, api.ErrSponsorRequired
}
c := &Easee{

View file

@ -2,7 +2,6 @@ package charger
import (
"encoding/binary"
"errors"
"fmt"
"github.com/andig/evcc/api"
@ -58,7 +57,7 @@ func NewHeidelbergEC(uri, device, comset string, baudrate int, slaveID uint8) (a
}
if !sponsor.IsAuthorized() {
return nil, errors.New("heidelberg requires evcc sponsorship, register at https://cloud.evcc.io")
return nil, api.ErrSponsorRequired
}
log := util.NewLogger("hec")

View file

@ -53,7 +53,7 @@ func NewTronityFromConfig(other map[string]interface{}) (api.Vehicle, error) {
}
if !sponsor.IsAuthorized() {
return nil, errors.New("tronity requires evcc sponsorship, register at https://cloud.evcc.io")
return nil, api.ErrSponsorRequired
}
// authenticated http client with logging injected to the tronity client