Standardize error messages by removing config prefix
This commit is contained in:
parent
3de1f3d072
commit
1e03a51eae
15 changed files with 23 additions and 31 deletions
|
|
@ -33,7 +33,7 @@ type Auth struct {
|
|||
// NewAuth creates authorization headers from config
|
||||
func NewAuth(log *util.Logger, auth Auth, headers map[string]string) {
|
||||
if strings.ToLower(auth.Type) != "basic" {
|
||||
log.FATAL.Fatalf("config: unsupported auth type: %s", auth.Type)
|
||||
log.FATAL.Fatalf("unsupported auth type: %s", auth.Type)
|
||||
}
|
||||
|
||||
basicAuth := auth.User + ":" + auth.Password
|
||||
|
|
@ -85,7 +85,7 @@ func NewHTTPProviderFromConfig(other map[string]interface{}) (*HTTP, error) {
|
|||
if cc.Jq != "" {
|
||||
op, err := gojq.Parse(cc.Jq)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("config: invalid jq query: %s", p.jq)
|
||||
return nil, fmt.Errorf("invalid jq query: %s", p.jq)
|
||||
}
|
||||
|
||||
p.jq = op
|
||||
|
|
|
|||
|
|
@ -55,18 +55,18 @@ func NewModbusFromConfig(other map[string]interface{}) (*Modbus, error) {
|
|||
var op modbus.Operation
|
||||
|
||||
if cc.Value != "" && cc.Register.Decode != "" {
|
||||
return nil, errors.New("config: modbus cannot have value and register both")
|
||||
return nil, errors.New("modbus cannot have value and register both")
|
||||
}
|
||||
|
||||
if cc.Value == "" && cc.Register.Decode == "" {
|
||||
log.WARN.Println("config: missing modbus value or register - assuming Power")
|
||||
log.WARN.Println("missing modbus value or register - assuming Power")
|
||||
cc.Value = "Power"
|
||||
}
|
||||
|
||||
// model + value configured
|
||||
if cc.Value != "" {
|
||||
if err := modbus.ParseOperation(device, cc.Value, &op); err != nil {
|
||||
return nil, fmt.Errorf("config: invalid value %s", cc.Value)
|
||||
return nil, fmt.Errorf("invalid value %s", cc.Value)
|
||||
}
|
||||
|
||||
// if sunspec reading configured make sure model is defined or device won't be initalized
|
||||
|
|
|
|||
|
|
@ -70,7 +70,7 @@ func NewSocketProviderFromConfig(other map[string]interface{}) (*Socket, error)
|
|||
if cc.Jq != "" {
|
||||
op, err := gojq.Parse(cc.Jq)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("config: invalid jq query: %s", p.jq)
|
||||
return nil, fmt.Errorf("invalid jq query: %s", p.jq)
|
||||
}
|
||||
|
||||
p.jq = op
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue