We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent b352a44 commit fdf5d95Copy full SHA for fdf5d95
internal/iot/error.go
@@ -18,6 +18,7 @@
18
package iot
19
20
import (
21
+ "encoding/json"
22
"fmt"
23
24
iotclient "github.com/arduino/iot-client-go"
@@ -32,9 +33,17 @@ func errorDetail(err error) error {
32
33
}
34
35
modErr, ok := apiErr.Model().(iotclient.ModelError)
- if !ok {
36
+ if ok {
37
+ return fmt.Errorf("%w: %s", err, modErr.Detail)
38
+ }
39
+
40
+ body := make(map[string]interface{})
41
+ if bodyErr := json.Unmarshal(apiErr.Body(), &body); bodyErr != nil {
42
return err
43
44
+ if detail, ok := body["detail"]; ok {
45
+ return fmt.Errorf("%w: %s", err, detail)
46
47
- return fmt.Errorf("%w: %s", err, modErr.Detail)
48
+ return err
49
0 commit comments