We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent b352a44 commit 975a828Copy full SHA for 975a828
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)
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
+ detail, ok := body["detail"]
45
if !ok {
46
return err
47
-
- return fmt.Errorf("%w: %s", err, modErr.Detail)
48
+ return fmt.Errorf("%w: %v", err, detail)
49
0 commit comments