From 2ef7db3519a5835260db63cb712ac4fae145bd61 Mon Sep 17 00:00:00 2001 From: Maneesha-rubix Date: Mon, 5 Aug 2024 17:16:41 +0530 Subject: [PATCH] improving error handling --- core/smartcontract_tokenchain_validation.go | 4 ++-- core/token_chain_validation.go | 4 ++-- server/tokens.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/core/smartcontract_tokenchain_validation.go b/core/smartcontract_tokenchain_validation.go index 9a036c40..5b7ae8e1 100644 --- a/core/smartcontract_tokenchain_validation.go +++ b/core/smartcontract_tokenchain_validation.go @@ -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 diff --git a/core/token_chain_validation.go b/core/token_chain_validation.go index 28e6576e..83495a81 100644 --- a/core/token_chain_validation.go +++ b/core/token_chain_validation.go @@ -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 diff --git a/server/tokens.go b/server/tokens.go index 77904d57..6ef7a1f6 100644 --- a/server/tokens.go +++ b/server/tokens.go @@ -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) } }