Skip to content

Commit

Permalink
added error check and fixed healtchcheck bug
Browse files Browse the repository at this point in the history
  • Loading branch information
fbuedding committed Mar 27, 2024
1 parent 4e8584d commit 20d262a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
20 changes: 20 additions & 0 deletions iota-config-group.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ func (i IoTA) ReadConfigGroup(fs FiwareService, r Resource, a Apikey) (*RespRead
}
var apiError ApiError
json.Unmarshal(resData, &apiError)
if err != nil {
return nil, fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host)
}

return nil, apiError
}

Expand Down Expand Up @@ -120,6 +124,10 @@ func (i IoTA) ListConfigGroups(fs FiwareService) (*RespReadConfigGroup, error) {
}
var apiError ApiError
json.Unmarshal(resData, &apiError)
if err != nil {
return nil, fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host)
}

return nil, apiError
}

Expand Down Expand Up @@ -186,6 +194,10 @@ func (i IoTA) CreateConfigGroups(fs FiwareService, sgs []ConfigGroup) error {
}
var apiError ApiError
json.Unmarshal(resData, &apiError)
if err != nil {
return fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host)
}

return apiError
}

Expand Down Expand Up @@ -230,6 +242,10 @@ func (i IoTA) UpdateConfigGroup(fs FiwareService, r Resource, a Apikey, sg Confi
}
var apiError ApiError
json.Unmarshal(resData, &apiError)
if err != nil {
return fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host)
}

return apiError
}

Expand Down Expand Up @@ -264,6 +280,10 @@ func (i IoTA) DeleteConfigGroup(fs FiwareService, r Resource, a Apikey) error {
}
var apiError ApiError
json.Unmarshal(resData, &apiError)
if err != nil {
return fmt.Errorf("Unexpected Error, is host %s a IoT-Agent?", i.Host)
}

return apiError
}

Expand Down
2 changes: 1 addition & 1 deletion iota-sdk.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (i IoTA) Healthcheck() (*RespHealthcheck, error) {
}
var respHealth RespHealthcheck
json.Unmarshal(responseData, &respHealth)
if respHealth.Version == "" {
if respHealth.LibVersion == "" {
return nil, fmt.Errorf("Error healtchecking IoT-Agent, host: %s", i.Host)
}
log.Debug().Str("Response healthcheck", string(responseData)).Any("Healthcheck", respHealth).Send()
Expand Down

0 comments on commit 20d262a

Please sign in to comment.