Skip to content

Commit ef7a9ed

Browse files
committed
return error from isTwinVerified function
1 parent 9495238 commit ef7a9ed

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

pkg/provision/engine.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,8 +1025,10 @@ func (n *NativeEngine) CreateOrUpdate(twin uint32, deployment gridtypes.Deployme
10251025

10261026
// make sure the account used is verified
10271027
check := func() error {
1028-
if !isTwinVerified(twin) {
1029-
return fmt.Errorf("user is not verified")
1028+
if ok, err := isTwinVerified(twin); err != nil {
1029+
return err
1030+
} else if !ok {
1031+
return fmt.Errorf("user with twin id %d is not verified", twin)
10301032
}
10311033
return nil
10321034
}
@@ -1190,7 +1192,7 @@ func (e *NativeEngine) GetWorkloadStatus(id string) (gridtypes.ResultState, bool
11901192
}
11911193

11921194
// isTwinVerified make sure the account used is verified
1193-
func isTwinVerified(twinID uint32) (verified bool) {
1195+
func isTwinVerified(twinID uint32) (verified bool, err error) {
11941196
const verifiedStatus = "VERIFIED"
11951197
env := environment.MustGet()
11961198

@@ -1219,8 +1221,7 @@ func isTwinVerified(twinID uint32) (verified bool) {
12191221
defer response.Body.Close()
12201222

12211223
if response.StatusCode != http.StatusOK {
1222-
log.Error().Msg("failed to get user status")
1223-
return
1224+
return verified, errors.New("failed to get twin verification status")
12241225
}
12251226

12261227
var result struct{ Result struct{ Status string } }
@@ -1230,5 +1231,5 @@ func isTwinVerified(twinID uint32) (verified bool) {
12301231
return
12311232
}
12321233

1233-
return result.Result.Status == verifiedStatus
1234+
return result.Result.Status == verifiedStatus, nil
12341235
}

0 commit comments

Comments
 (0)