Change the way vehicle errors are silenced
This commit is contained in:
parent
f0a5769240
commit
5ff3b10f34
2 changed files with 4 additions and 4 deletions
|
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/evcc-io/evcc/push"
|
||||
"github.com/evcc-io/evcc/server"
|
||||
"github.com/evcc-io/evcc/vehicle"
|
||||
"github.com/evcc-io/evcc/vehicle/wrapper"
|
||||
)
|
||||
|
||||
type config struct {
|
||||
|
|
@ -167,7 +168,8 @@ func (cp *ConfigProvider) configureVehicles(conf config) error {
|
|||
|
||||
v, err := vehicle.NewFromConfig(cc.Type, cc.Other)
|
||||
if err != nil {
|
||||
return fmt.Errorf("cannot create vehicle '%s': %w", cc.Name, err)
|
||||
// wrap any created errors to prevent fatals
|
||||
v, _ = wrapper.New(v, err)
|
||||
}
|
||||
|
||||
if _, exists := cp.vehicles[cc.Name]; exists {
|
||||
|
|
|
|||
|
|
@ -6,7 +6,6 @@ import (
|
|||
"time"
|
||||
|
||||
"github.com/evcc-io/evcc/api"
|
||||
"github.com/evcc-io/evcc/vehicle/wrapper"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
@ -47,8 +46,7 @@ func NewFromConfig(typ string, other map[string]interface{}) (v api.Vehicle, err
|
|||
factory, err := registry.Get(strings.ToLower(typ))
|
||||
if err == nil {
|
||||
if v, err = factory(other); err != nil {
|
||||
// wrap any created errors to prevent fatals
|
||||
v, err = wrapper.New(v, err)
|
||||
err = fmt.Errorf("cannot create vehicle '%s': %w", typ, err)
|
||||
}
|
||||
} else {
|
||||
err = fmt.Errorf("invalid vehicle type: %s", typ)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue