From 1f5794b316e88075b4f316fb125963a1b3b09d50 Mon Sep 17 00:00:00 2001 From: Anna Shaleva Date: Wed, 29 Jul 2020 14:31:16 +0300 Subject: [PATCH] rpc: make `getDecimals` return a standard error `getDecimals` is an internal method, wo there's no need to return response.Error. --- pkg/rpc/server/server.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/rpc/server/server.go b/pkg/rpc/server/server.go index 9d17c71c5..ca376f692 100644 --- a/pkg/rpc/server/server.go +++ b/pkg/rpc/server/server.go @@ -590,7 +590,7 @@ func amountToString(amount *big.Int, decimals int64) string { return fmt.Sprintf(fs, q, r) } -func (s *Server) getDecimals(h util.Uint160, cache map[util.Uint160]int64) (int64, *response.Error) { +func (s *Server) getDecimals(h util.Uint160, cache map[util.Uint160]int64) (int64, error) { if d, ok := cache[h]; ok { return d, nil } @@ -605,11 +605,11 @@ func (s *Server) getDecimals(h util.Uint160, cache map[util.Uint160]int64) (int6 }, }) if err != nil { - return 0, response.NewInternalServerError("Can't create script", err) + return 0, fmt.Errorf("can't create script: %v", err) } res := s.runScriptInVM(script, nil) if res == nil || res.State != "HALT" || len(res.Stack) == 0 { - return 0, response.NewInternalServerError("execution error", errors.New("no result")) + return 0, errors.New("execution error : no result") } var d int64 @@ -619,10 +619,10 @@ func (s *Server) getDecimals(h util.Uint160, cache map[util.Uint160]int64) (int6 case smartcontract.ByteArrayType: d = bigint.FromBytes(item.Value.([]byte)).Int64() default: - return 0, response.NewInternalServerError("invalid result", errors.New("not an integer")) + return 0, errors.New("invalid result: not an integer") } if d < 0 { - return 0, response.NewInternalServerError("incorrect result", errors.New("negative result")) + return 0, errors.New("incorrect result: negative result") } cache[h] = d return d, nil