chore: add template name to error messages (#26259)

This commit is contained in:
andig 2025-12-30 19:09:44 +01:00 • committed by GitHub
parent 382af7a871
commit f93b15a8c1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 35 additions and 10 deletions

View file

@ -6,6 +6,7 @@ import (
"strings"
"github.com/evcc-io/evcc/api"
"github.com/evcc-io/evcc/util"
reg "github.com/evcc-io/evcc/util/registry"
)
@ -25,7 +26,7 @@ func NewFromConfig(ctx context.Context, typ string, other map[string]any) (api.T
v, err := factory(ctx, other)
if err != nil {
return nil, fmt.Errorf("cannot create tariff type '%s': %w", typ, err)
return nil, fmt.Errorf("cannot create tariff type '%s': %w", util.TypeWithTemplateName(typ, other), err)
}
// check slot length

View file

@ -33,10 +33,8 @@ var _ api.Tariff = (*cachingProxy)(nil)
// NewCachedFromConfig creates a proxy that controls tariff instantiation and caching
func NewCachedFromConfig(ctx context.Context, typ string, other map[string]any) (api.Tariff, error) {
tariffType := typ
if typ == "template" {
if template, ok := other["template"].(string); ok {
tariffType = template
}
if template := util.TemplateName(typ, other); template != "" {
tariffType = template
}
p := &cachingProxy{