feat: decode conf error msg
This commit is contained in:
parent
7b3edb2361
commit
3682a36fde
|
@ -1,12 +1,16 @@
|
||||||
package stage
|
package stage
|
||||||
|
|
||||||
import "github.com/mitchellh/mapstructure"
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"github.com/mitchellh/mapstructure"
|
||||||
|
)
|
||||||
|
|
||||||
func DecodeConf[T any](confAny any) (*T, error) {
|
func DecodeConf[T any](confAny any) (*T, error) {
|
||||||
var conf T
|
var conf T
|
||||||
err := mapstructure.Decode(confAny, &conf)
|
err := mapstructure.Decode(confAny, &conf)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, fmt.Errorf("failed to decode conf: %w", err)
|
||||||
}
|
}
|
||||||
return &conf, nil
|
return &conf, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user