Skip to content

Commit

Permalink
improving error handling
Browse files Browse the repository at this point in the history
  • Loading branch information
maneeSHA-256 committed Aug 5, 2024
1 parent 4262d5c commit 2ef7db3
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions core/smartcontract_tokenchain_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ func (c *Core) SmartContractTokenChainValidation(user_did string, tokenId string
}
ok := c.w.IsDIDExist(user_did)
if !ok {
response.Message = "Invalid did"
return response, fmt.Errorf("invalid did: %v", user_did)
response.Message = "Invalid did, please pass did of the tokenchain validator"
return response, fmt.Errorf("invalid did: %v, please pass did of the tokenchain validator", user_did)
}

if tokenId == "" { //if provided the boolean flag 'allmyToken', all the tokens' chain from tokens table will be validated
Expand Down
4 changes: 2 additions & 2 deletions core/token_chain_validation.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ func (c *Core) TokenChainValidation(user_did string, tokenId string, blockCount
}
ok := c.w.IsDIDExist(user_did)
if !ok {
response.Message = "Invalid did"
return response, fmt.Errorf("invalid did: %v", user_did)
response.Message = "Invalid did, please pass did of the tokenchain validator"
return response, fmt.Errorf("invalid did: %v, please pass did of the tokenchain validator", user_did)
}

if tokenId == "" { //if provided the boolean flag 'allmyToken', all the tokens' chain from tokens table will be validated
Expand Down
4 changes: 2 additions & 2 deletions server/tokens.go
Original file line number Diff line number Diff line change
Expand Up @@ -330,13 +330,13 @@ func (s *Server) APIValidateTokenChain(req *ensweb.Request) *ensweb.Result {
s.log.Debug("validating smart contract")
br, err = s.c.SmartContractTokenChainValidation(user_did, token, blockCount)
if err != nil {
return s.BasicResponse(req, false, "Failed to validate token(s)", nil)
return s.BasicResponse(req, false, br.Message, nil)
}
} else {
s.log.Debug("validating rbt token")
br, err = s.c.TokenChainValidation(user_did, token, blockCount)
if err != nil {
return s.BasicResponse(req, false, "Failed to validate token(s)", nil)
return s.BasicResponse(req, false, br.Message, nil)
}
}

Expand Down

0 comments on commit 2ef7db3

Please sign in to comment.