Skip to content
Snippets Groups Projects
Commit 013a3d9f authored by Damyan Mitev's avatar Damyan Mitev :beach:
Browse files

Change missing keys error handling

parent ae2ddbda
No related branches found
No related tags found
1 merge request!57Refactor EMA error handling
...@@ -100,7 +100,9 @@ func (s *KeyStorageServerImpl) updateAll(ctx context.Context, uuid string, updat ...@@ -100,7 +100,9 @@ func (s *KeyStorageServerImpl) updateAll(ctx context.Context, uuid string, updat
for _, kType := range []api.KeyType{api.KeyType_PRIVATE, api.KeyType_PUBLIC, api.KeyType_CERTIFICATE} { for _, kType := range []api.KeyType{api.KeyType_PRIVATE, api.KeyType_PUBLIC, api.KeyType_CERTIFICATE} {
err := updateKey(client, uuid, kType, updateFunc) err := updateKey(client, uuid, kType, updateFunc)
if err != nil { if err != nil {
return err if !errors.Wraps(err, keyutils.ErrNoData) {
return err
}
} }
} }
......
...@@ -37,6 +37,8 @@ import ( ...@@ -37,6 +37,8 @@ import (
"code.vereign.com/code/viam-apis/key-storage-agent/api" "code.vereign.com/code/viam-apis/key-storage-agent/api"
) )
var ErrNoData = errors.New("No data")
func GenerateUnusedUUID(client *client.DataStorageClientImpl) (string, error) { func GenerateUnusedUUID(client *client.DataStorageClientImpl) (string, error) {
count := 0 count := 0
for { for {
...@@ -145,8 +147,7 @@ func GetKey(client *client.DataStorageClientImpl, uuid string, keyType api.KeyTy ...@@ -145,8 +147,7 @@ func GetKey(client *client.DataStorageClientImpl, uuid string, keyType api.KeyTy
} }
if !hasData { if !hasData {
err = errors.New("No data") return nil, errors.WrapUserFormat(ErrNoData, "Could not get key %s", uuid+"/"+api.KeyType.String(keyType))
return nil, errors.WrapUserFormat(err, "Could not get key %s", uuid+"/"+api.KeyType.String(keyType))
} }
return key, nil return key, nil
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment