Skip to content

Commit

Permalink
refactor: didDoc and credentialStatus doc will throw proper error sta…
Browse files Browse the repository at this point in the history
…tus codes
  • Loading branch information
arnabghose997 committed Mar 2, 2023
1 parent be2da81 commit 45b9fa7
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 3 deletions.
3 changes: 2 additions & 1 deletion x/ssi/keeper/grpc_query_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"
"github.com/hypersign-protocol/hid-node/x/ssi/types"
"google.golang.org/grpc/codes"
Expand All @@ -19,7 +20,7 @@ func (k Keeper) QueryCredential(goCtx context.Context, req *types.QueryCredentia

cred, err := k.GetCredentialStatusFromState(&ctx, req.CredId)
if err != nil {
return nil, err
return nil, sdkerrors.Wrap(types.ErrCredentialStatusNotFound, err.Error())
}

return &types.QueryCredentialResponse{CredStatus: cred}, nil
Expand Down
3 changes: 2 additions & 1 deletion x/ssi/keeper/grpc_query_did.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/cosmos/cosmos-sdk/store/prefix"
sdk "github.com/cosmos/cosmos-sdk/types"
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
"github.com/cosmos/cosmos-sdk/types/query"

"github.com/hypersign-protocol/hid-node/x/ssi/types"
Expand Down Expand Up @@ -60,7 +61,7 @@ func (k Keeper) QueryDidDocument(goCtx context.Context, req *types.QueryDidDocum
// Check if DID Document exists
didDoc, err := k.GetDidDocumentState(&ctx, req.DidId)
if err != nil {
return nil, err
return nil, sdkerrors.Wrap(types.ErrDidDocNotFound, err.Error())
}

return &types.QueryDidDocumentResponse{
Expand Down
2 changes: 1 addition & 1 deletion x/ssi/keeper/msg_server_credential.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (k msgServer) updateCredentialStatus(ctx sdk.Context, msg *types.MsgRegiste
// Get Credential from store
oldCredStatus, err := k.GetCredentialStatusFromState(&ctx, credId)
if err != nil {
return nil, err
return nil, sdkerrors.Wrap(types.ErrCredentialStatusNotFound, err.Error())
}

// Check if the DID of the issuer exists
Expand Down
1 change: 1 addition & 0 deletions x/ssi/types/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,4 +22,5 @@ var (
ErrInvalidCredentialField = sdkerrors.Register(ModuleName, 112, "invalid Credential Field")
ErrInvalidCredentialHash = sdkerrors.Register(ModuleName, 113, "invalid Credential Hash")
ErrInvalidClientSpecType = sdkerrors.Register(ModuleName, 114, "invalid Client Spec Type")
ErrCredentialStatusNotFound = sdkerrors.Register(ModuleName, 115, "credentialStatus document not found")
)

0 comments on commit 45b9fa7

Please sign in to comment.