diff options
author | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 03:31:00 +0800 |
---|---|---|
committer | Taylor Gerring <taylor.gerring@gmail.com> | 2015-03-27 03:31:00 +0800 |
commit | 81f36df910533de63dc5ac66f38b5481961cc0c8 (patch) | |
tree | 3c6bf52b299ae7dba1b7409632ab500d10a915e7 /rpc/args.go | |
parent | ddcc8e1673f240556f7a9394d5fbc9ed609a4931 (diff) | |
download | dexon-81f36df910533de63dc5ac66f38b5481961cc0c8.tar dexon-81f36df910533de63dc5ac66f38b5481961cc0c8.tar.gz dexon-81f36df910533de63dc5ac66f38b5481961cc0c8.tar.bz2 dexon-81f36df910533de63dc5ac66f38b5481961cc0c8.tar.lz dexon-81f36df910533de63dc5ac66f38b5481961cc0c8.tar.xz dexon-81f36df910533de63dc5ac66f38b5481961cc0c8.tar.zst dexon-81f36df910533de63dc5ac66f38b5481961cc0c8.zip |
CompileArgs
Diffstat (limited to 'rpc/args.go')
-rw-r--r-- | rpc/args.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/rpc/args.go b/rpc/args.go index c11ffa3cc..0169ece58 100644 --- a/rpc/args.go +++ b/rpc/args.go @@ -617,14 +617,18 @@ type CompileArgs struct { func (args *CompileArgs) UnmarshalJSON(b []byte) (err error) { var obj []interface{} - r := bytes.NewReader(b) - if err := json.NewDecoder(r).Decode(&obj); err != nil { + if err := json.Unmarshal(b, &obj); err != nil { return NewDecodeParamError(err.Error()) } - if len(obj) > 0 { - args.Source = obj[0].(string) + if len(obj) < 1 { + return NewInsufficientParamsError(len(obj), 1) + } + argstr, ok := obj[0].(string) + if !ok { + return NewInvalidTypeError("arg0", "is not a string") } + args.Source = argstr return nil } |