chore: add ErrMissingCredentials

This commit is contained in:
andig 2021-11-18 12:11:19 +01:00
parent 9b16f9bcf2
commit a35eff7c7b
11 changed files with 26 additions and 10 deletions

View file

@ -11,6 +11,9 @@ var ErrMustRetry = errors.New("must retry")
// ErrSponsorRequired indicates that a sponsor token is required
var ErrSponsorRequired = errors.New("sponsorship required, see https://github.com/evcc-io/evcc#sponsorship")
// ErrMissingCredentials indicates that user/password are missing
var ErrMissingCredentials = errors.New("missing credentials")
// ErrTimeout is the error returned when a timeout happened.
// Modeled after context.DeadlineError
var ErrTimeout error = errTimeoutError{}

View file

@ -44,6 +44,10 @@ func NewBMWMiniFromConfig(brand string, other map[string]interface{}) (api.Vehic
return nil, err
}
if cc.User == "" || cc.Password == "" {
return nil, api.ErrMissingCredentials
}
v := &BMW{
embed: &cc.embed,
}

View file

@ -52,7 +52,7 @@ func NewCarWingsFromConfig(other map[string]interface{}) (api.Vehicle, error) {
}
if cc.User == "" || cc.Password == "" {
return nil, errors.New("missing credentials")
return nil, api.ErrMissingCredentials
}
log := util.NewLogger("carwings").Redact(cc.User, cc.Password, cc.VIN)

View file

@ -1,7 +1,6 @@
package vehicle
import (
"errors"
"fmt"
"strings"
"time"
@ -40,7 +39,7 @@ func NewFiatFromConfig(other map[string]interface{}) (api.Vehicle, error) {
}
if cc.User == "" || cc.Password == "" {
return nil, errors.New("missing credentials")
return nil, api.ErrMissingCredentials
}
v := &Fiat{

View file

@ -56,7 +56,7 @@ func NewFordFromConfig(other map[string]interface{}) (api.Vehicle, error) {
}
if cc.User == "" || cc.Password == "" {
return nil, errors.New("missing credentials")
return nil, api.ErrMissingCredentials
}
log := util.NewLogger("ford").Redact(cc.User, cc.Password, cc.VIN)

View file

@ -1,7 +1,6 @@
package vehicle
import (
"errors"
"fmt"
"strings"
"time"
@ -39,7 +38,7 @@ func NewHyundaiFromConfig(other map[string]interface{}) (api.Vehicle, error) {
}
if cc.User == "" || cc.Password == "" {
return nil, errors.New("missing credentials")
return nil, api.ErrMissingCredentials
}
log := util.NewLogger("hyundai").Redact(cc.User, cc.Password, cc.VIN)

View file

@ -1,7 +1,6 @@
package vehicle
import (
"errors"
"fmt"
"strings"
"time"
@ -39,7 +38,7 @@ func NewKiaFromConfig(other map[string]interface{}) (api.Vehicle, error) {
}
if cc.User == "" || cc.Password == "" {
return nil, errors.New("missing credentials")
return nil, api.ErrMissingCredentials
}
log := util.NewLogger("kia").Redact(cc.User, cc.Password, cc.VIN)

View file

@ -44,6 +44,10 @@ func NewNissanFromConfig(other map[string]interface{}) (api.Vehicle, error) {
return nil, err
}
if cc.User == "" || cc.Password == "" {
return nil, api.ErrMissingCredentials
}
v := &Nissan{
embed: &cc.embed,
}

View file

@ -42,6 +42,10 @@ func NewPorscheFromConfig(other map[string]interface{}) (api.Vehicle, error) {
return nil, err
}
if cc.User == "" || cc.Password == "" {
return nil, api.ErrMissingCredentials
}
log := util.NewLogger("porsche").Redact(cc.User, cc.Password, cc.VIN)
identity := porsche.NewIdentity(log, cc.User, cc.Password)

View file

@ -81,6 +81,10 @@ func newPSA(log *util.Logger, brand, realm, id, secret string, other map[string]
return nil, err
}
if cc.User == "" || cc.Password == "" {
return nil, api.ErrMissingCredentials
}
v := &PSA{
embed: &cc.embed,
}

View file

@ -1,13 +1,13 @@
package vw
import (
"errors"
"fmt"
"net/http"
"net/http/cookiejar"
"net/url"
"strings"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
"github.com/evcc-io/evcc/util/request"
"golang.org/x/net/publicsuffix"
@ -57,7 +57,7 @@ func NewIdentity(log *util.Logger) *Identity {
// UserLogin performs the identity.vwgroup.io login
func (v *Identity) UserLogin(uri, user, password string) (url.Values, error) {
if user == "" || password == "" {
return nil, errors.New("missing credentials")
return nil, api.ErrMissingCredentials
}
// track cookies and don't follow redirects