aboutsummaryrefslogtreecommitdiffstats
path: root/core/vm/sqlvm/parser
diff options
context:
space:
mode:
authoryenlin.lai <yenlin.lai@cobinhood.com>2019-03-29 10:51:32 +0800
committerJhih-Ming Huang <jm.huang@cobinhood.com>2019-04-11 10:39:59 +0800
commitae32646fd86f0aa102adb788a4050badc38db918 (patch)
tree7da53bf9d5627a9f9bcfaa75fcc1fdaf8b9b6498 /core/vm/sqlvm/parser
parentd6fcba4ee624241128e1f086a6b20c3c75bf928c (diff)
downloaddexon-ae32646fd86f0aa102adb788a4050badc38db918.tar
dexon-ae32646fd86f0aa102adb788a4050badc38db918.tar.gz
dexon-ae32646fd86f0aa102adb788a4050badc38db918.tar.bz2
dexon-ae32646fd86f0aa102adb788a4050badc38db918.tar.lz
dexon-ae32646fd86f0aa102adb788a4050badc38db918.tar.xz
dexon-ae32646fd86f0aa102adb788a4050badc38db918.tar.zst
dexon-ae32646fd86f0aa102adb788a4050badc38db918.zip
vm: sqlvm: refine after updating dexon-foundation/decimal
Refine behaviors: 1. Check decimal.NewFromString by type instead of string compare. 2. Use Rescale in DecimalEncode.
Diffstat (limited to 'core/vm/sqlvm/parser')
-rw-r--r--core/vm/sqlvm/parser/internal/helpers.go9
1 files changed, 3 insertions, 6 deletions
diff --git a/core/vm/sqlvm/parser/internal/helpers.go b/core/vm/sqlvm/parser/internal/helpers.go
index 386a4be7e..91b73b8ad 100644
--- a/core/vm/sqlvm/parser/internal/helpers.go
+++ b/core/vm/sqlvm/parser/internal/helpers.go
@@ -5,7 +5,6 @@ import (
"encoding/hex"
"fmt"
"strconv"
- "strings"
"unicode/utf8"
"github.com/dexon-foundation/decimal"
@@ -106,12 +105,10 @@ func convertDecimalError(err error) errors.ErrorCode {
if err == nil {
return errors.ErrorCodeNil
}
- errStr := err.Error()
- if strings.HasSuffix(errStr, "decimal: fractional part too long") {
+ switch err.(type) {
+ case *decimal.ErrorExponentLimit:
return errors.ErrorCodeFractionalPartTooLong
- } else if strings.HasSuffix(errStr, "decimal: exponent is not numeric") {
- return errors.ErrorCodeInvalidNumberSyntax
- } else if strings.HasSuffix(errStr, "decimal: too many .s") {
+ case *decimal.ErrorInvalidFormat:
return errors.ErrorCodeInvalidNumberSyntax
}
panic(fmt.Sprintf("unknown decimal error: %v", err))