Skip to content

Commit 047ad65

Browse files
committed
Refactored print error
1 parent 496ddcf commit 047ad65

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

command/ota/upload.go

+5-3
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ package ota
1919

2020
import (
2121
"context"
22+
"errors"
2223
"fmt"
2324
"os"
2425
"path/filepath"
@@ -104,14 +105,15 @@ func Upload(ctx context.Context, params *UploadParams, cred *config.Credentials)
104105
var conflictedOta *otaapi.Ota
105106
err = iotClient.DeviceOTA(ctx, params.DeviceID, file, expiration)
106107
if err != nil {
107-
if err == iot.ErrOtaAlreadyInProgress {
108+
if errors.Is(err, iot.ErrOtaAlreadyInProgress) {
108109
conflictedOta = &otaapi.Ota{
109110
DeviceID: params.DeviceID,
110-
Status: "Failed",
111+
Status: "Skipped",
111112
ErrorReason: "OTA already in progress",
112113
}
114+
} else {
115+
return err
113116
}
114-
return err
115117
}
116118
// Try to get ota-id from API
117119
otaID, err := otapi.GetOtaLastStatusByDeviceID(params.DeviceID)

internal/iot/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"golang.org/x/oauth2"
2929
)
3030

31-
var ErrOtaAlreadyInProgress = fmt.Errorf("already in progress")
31+
var ErrOtaAlreadyInProgress = fmt.Errorf("ota already in progress")
3232

3333
// Client can perform actions on Arduino IoT Cloud.
3434
type Client struct {

0 commit comments

Comments
 (0)