aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/args.go
diff options
context:
space:
mode:
authorTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 20:45:06 +0800
committerTaylor Gerring <taylor.gerring@gmail.com>2015-03-26 20:45:06 +0800
commita49c81547ce32125917c0127c94c9845750e9e30 (patch)
tree89687e9e4ee4716ed3325e1e28c0a3e0bdd3b4f6 /rpc/args.go
parentca03e976976a03d278da227fe1ec9966f23484ba (diff)
downloaddexon-a49c81547ce32125917c0127c94c9845750e9e30.tar
dexon-a49c81547ce32125917c0127c94c9845750e9e30.tar.gz
dexon-a49c81547ce32125917c0127c94c9845750e9e30.tar.bz2
dexon-a49c81547ce32125917c0127c94c9845750e9e30.tar.lz
dexon-a49c81547ce32125917c0127c94c9845750e9e30.tar.xz
dexon-a49c81547ce32125917c0127c94c9845750e9e30.tar.zst
dexon-a49c81547ce32125917c0127c94c9845750e9e30.zip
DecodeParamError -> InvalidTypeError for unexpected input type
Diffstat (limited to 'rpc/args.go')
-rw-r--r--rpc/args.go54
1 files changed, 27 insertions, 27 deletions
diff --git a/rpc/args.go b/rpc/args.go
index 81343dd01..30ed1a17c 100644
--- a/rpc/args.go
+++ b/rpc/args.go
@@ -27,7 +27,7 @@ func blockHeight(raw interface{}, number *int64) error {
// Parse as string/hexstring
str, ok := raw.(string)
if !ok {
- return NewDecodeParamError("BlockNumber is not a number or string")
+ return NewInvalidTypeError("blockNumber", "not a number or string")
}
switch str {
@@ -60,7 +60,7 @@ func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) {
argstr, ok := obj[0].(string)
if !ok {
- return NewDecodeParamError("BlockHash not a string")
+ return NewInvalidTypeError("blockHash", "not a string")
}
args.BlockHash = common.HexToHash(argstr)
@@ -92,7 +92,7 @@ func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
} else if v, ok := obj[0].(string); ok {
args.BlockNumber = common.Big(v).Int64()
} else {
- return NewDecodeParamError("blockNumber must be number or string")
+ return NewInvalidTypeError("blockNumber", "not a number or string")
}
if len(obj) > 1 {
@@ -170,7 +170,7 @@ func (args *GetStorageArgs) UnmarshalJSON(b []byte) (err error) {
addstr, ok := obj[0].(string)
if !ok {
- return NewDecodeParamError("address is not a string")
+ return NewInvalidTypeError("address", "not a string")
}
args.Address = common.HexToAddress(addstr)
@@ -201,13 +201,13 @@ func (args *GetStorageAtArgs) UnmarshalJSON(b []byte) (err error) {
addstr, ok := obj[0].(string)
if !ok {
- return NewDecodeParamError("Address is not a string")
+ return NewInvalidTypeError("address", "not a string")
}
args.Address = common.HexToAddress(addstr)
keystr, ok := obj[1].(string)
if !ok {
- return NewDecodeParamError("Key is not a string")
+ return NewInvalidTypeError("key", "not a string")
}
args.Key = common.HexToHash(keystr)
@@ -237,7 +237,7 @@ func (args *GetTxCountArgs) UnmarshalJSON(b []byte) (err error) {
addstr, ok := obj[0].(string)
if !ok {
- return NewDecodeParamError("Address is not a string")
+ return NewInvalidTypeError("address", "not a string")
}
args.Address = common.HexToAddress(addstr)
@@ -267,7 +267,7 @@ func (args *GetBalanceArgs) UnmarshalJSON(b []byte) (err error) {
addstr, ok := obj[0].(string)
if !ok {
- return NewDecodeParamError("Address is not a string")
+ return NewInvalidTypeError("address", "not a string")
}
args.Address = common.HexToAddress(addstr)
@@ -297,7 +297,7 @@ func (args *GetDataArgs) UnmarshalJSON(b []byte) (err error) {
addstr, ok := obj[0].(string)
if !ok {
- return NewDecodeParamError("Address is not a string")
+ return NewInvalidTypeError("address", "not a string")
}
args.Address = addstr
@@ -335,14 +335,14 @@ func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
arg0, ok := obj[0].(string)
if !ok {
- return NewDecodeParamError("BlockNumber is not string")
+ return NewInvalidTypeError("blockNumber", "not a string")
}
args.BlockNumber = common.Big(arg0).Int64()
if len(obj) > 1 {
arg1, ok := obj[1].(string)
if !ok {
- return NewDecodeParamError("Index not a string")
+ return NewInvalidTypeError("index", "not a string")
}
args.Index = common.Big(arg1).Int64()
}
@@ -368,14 +368,14 @@ func (args *HashIndexArgs) UnmarshalJSON(b []byte) (err error) {
arg0, ok := obj[0].(string)
if !ok {
- return NewDecodeParamError("Hash not a string")
+ return NewInvalidTypeError("hash", "not a string")
}
args.Hash = arg0
if len(obj) > 1 {
arg1, ok := obj[1].(string)
if !ok {
- return NewDecodeParamError("Index not a string")
+ return NewInvalidTypeError("index", "not a string")
}
args.Index = common.Big(arg1).Int64()
}
@@ -431,7 +431,7 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
fromstr, ok := obj[0].FromBlock.(string)
if !ok {
- return NewDecodeParamError("FromBlock is not a string")
+ return NewInvalidTypeError("fromBlock", "is not a string")
}
switch fromstr {
@@ -443,7 +443,7 @@ func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
tostr, ok := obj[0].ToBlock.(string)
if !ok {
- return NewDecodeParamError("ToBlock is not a string")
+ return NewInvalidTypeError("toBlock", "not a string")
}
switch tostr {
@@ -483,19 +483,19 @@ func (args *DbArgs) UnmarshalJSON(b []byte) (err error) {
var ok bool
if objstr, ok = obj[0].(string); !ok {
- return NewDecodeParamError("Database is not a string")
+ return NewInvalidTypeError("database", "not a string")
}
args.Database = objstr
if objstr, ok = obj[1].(string); !ok {
- return NewDecodeParamError("Key is not a string")
+ return NewInvalidTypeError("key", "not a string")
}
args.Key = objstr
if len(obj) > 2 {
objstr, ok = obj[2].(string)
if !ok {
- return NewDecodeParamError("Value is not a string")
+ return NewInvalidTypeError("value", "not a string")
}
args.Value = []byte(objstr)
@@ -534,19 +534,19 @@ func (args *DbHexArgs) UnmarshalJSON(b []byte) (err error) {
var ok bool
if objstr, ok = obj[0].(string); !ok {
- return NewDecodeParamError("Database is not a string")
+ return NewInvalidTypeError("database", "not a string")
}
args.Database = objstr
if objstr, ok = obj[1].(string); !ok {
- return NewDecodeParamError("Key is not a string")
+ return NewInvalidTypeError("key", "not a string")
}
args.Key = objstr
if len(obj) > 2 {
objstr, ok = obj[2].(string)
if !ok {
- return NewDecodeParamError("Value is not a string")
+ return NewInvalidTypeError("value", "not a string")
}
args.Value = common.FromHex(objstr)
@@ -557,10 +557,10 @@ func (args *DbHexArgs) UnmarshalJSON(b []byte) (err error) {
func (a *DbHexArgs) requirements() error {
if len(a.Database) == 0 {
- return NewValidationError("Database", "cannot be blank")
+ return NewInvalidTypeError("Database", "cannot be blank")
}
if len(a.Key) == 0 {
- return NewValidationError("Key", "cannot be blank")
+ return NewInvalidTypeError("Key", "cannot be blank")
}
return nil
}
@@ -637,7 +637,7 @@ func (args *FilterStringArgs) UnmarshalJSON(b []byte) (err error) {
var argstr string
argstr, ok := obj[0].(string)
if !ok {
- return NewDecodeParamError("Filter is not a string")
+ return NewInvalidTypeError("filter", "not a string")
}
args.Word = argstr
@@ -741,18 +741,18 @@ func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) {
var objstr string
var ok bool
if objstr, ok = obj[0].(string); !ok {
- return NewDecodeParamError("Nonce is not a string")
+ return NewInvalidTypeError("nonce", "not a string")
}
args.Nonce = common.String2Big(objstr).Uint64()
if objstr, ok = obj[1].(string); !ok {
- return NewDecodeParamError("Header is not a string")
+ return NewInvalidTypeError("header", "not a string")
}
args.Header = common.HexToHash(objstr)
if objstr, ok = obj[2].(string); !ok {
- return NewDecodeParamError("Digest is not a string")
+ return NewInvalidTypeError("digest", "not a string")
}
args.Digest = common.HexToHash(objstr)