Skip to content
This repository was archived by the owner on Jun 29, 2024. It is now read-only.

Commit bdc592f

Browse files
committed
Fix possible panic
1 parent 45bbc67 commit bdc592f

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

emobility/results.go

+7-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package emobility
22

33
import (
4+
"fmt"
5+
46
"github.com/enbility/spine-go/api"
57
"github.com/enbility/spine-go/model"
68
)
@@ -35,6 +37,10 @@ func (e *EMobility) handleResultDeviceDiagnosis(resultMsg api.ResultMessage) {
3537
if len(datagram.Payload.Cmd) > 0 &&
3638
datagram.Payload.Cmd[0].DeviceDiagnosisHeartbeatData != nil {
3739
// something is horribly wrong, disconnect and hope a new connection will fix it
38-
e.service.DisconnectSKI(resultMsg.DeviceRemote.Ski(), string(*resultMsg.Result.Description))
40+
errorText := fmt.Sprintf("Error Code: %d", resultMsg.Result.ErrorNumber)
41+
if resultMsg.Result.Description != nil {
42+
errorText = fmt.Sprintf("%s - %s", errorText, string(*resultMsg.Result.Description))
43+
}
44+
e.service.DisconnectSKI(resultMsg.DeviceRemote.Ski(), errorText)
3945
}
4046
}

0 commit comments

Comments
 (0)