jsonrpctcp 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jsonrpctcp/client.rb +1 -1
- data/lib/jsonrpctcp/errors.rb +10 -4
- data/lib/jsonrpctcp/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68311fc0c0ee5820313079ba0cf278ae3e66e4be
|
4
|
+
data.tar.gz: 7b5b03da4ed6f2fecf18c38d64390b6bf517c09a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55fd92944822e4ed740498c4aff6b91b78cf4c43e053651c972dce7fa064c42d652e5854bcd7def595d1568d8919d65caac6a7b6948703ada90c18280e9bf522
|
7
|
+
data.tar.gz: 8c07318ac8507d320d917c37b09c5b378af51e159e489e123f7ff25755bb3843776286fe4de3b764ce09dc9e28d12e7089f7135bcdaea15eb8adefb119e235c2
|
data/lib/jsonrpctcp/client.rb
CHANGED
@@ -41,7 +41,7 @@ module Jsonrpctcp
|
|
41
41
|
# @return [TrueClass,FalseClass] returns whether a
|
42
42
|
# response does have an error key
|
43
43
|
def self.is_error?(response)
|
44
|
-
return response.has_key?('error')
|
44
|
+
return !response || !response.is_a?(Hash) || response.has_key?('error')
|
45
45
|
end
|
46
46
|
|
47
47
|
# Allows to call RPC methods as if they were defined functions:
|
data/lib/jsonrpctcp/errors.rb
CHANGED
@@ -24,7 +24,7 @@ module Jsonrpctcp
|
|
24
24
|
# A custom error for the library
|
25
25
|
class RPCError < StandardError
|
26
26
|
attr_reader :code, :message, :source_object
|
27
|
-
# RPC erros allow quick access to the code, the message and the
|
27
|
+
# RPC erros allow quick access to the code, the message and the
|
28
28
|
# source error object returned by the server
|
29
29
|
# @param message [String] Error message
|
30
30
|
# @param code [Fixnum] Error code
|
@@ -38,9 +38,15 @@ module Jsonrpctcp
|
|
38
38
|
# Creates a RPCError directly from a RPC response
|
39
39
|
# @param r [Hash] a parsed response
|
40
40
|
def self.from_rpc_response(r)
|
41
|
-
|
42
|
-
|
43
|
-
|
41
|
+
if r.nil? || !r.is_a?(Hash)
|
42
|
+
return RPCError.new("Empty response",
|
43
|
+
nil,
|
44
|
+
{})
|
45
|
+
else
|
46
|
+
return RPCError.new(r['error']['message'],
|
47
|
+
r['error']['code'],
|
48
|
+
r)
|
49
|
+
end
|
44
50
|
end
|
45
51
|
end
|
46
52
|
end
|
data/lib/jsonrpctcp/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jsonrpctcp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hector Sanjuan
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|