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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 9b2ec13dc2d8cc2125c1dc44afc8024b78ad9016
4
- data.tar.gz: 5d9c78073f4208511c21d6c80d1ebecd56282b41
3
+ metadata.gz: 68311fc0c0ee5820313079ba0cf278ae3e66e4be
4
+ data.tar.gz: 7b5b03da4ed6f2fecf18c38d64390b6bf517c09a
5
5
  SHA512:
6
- metadata.gz: d55187d9d3d307a5737367f51118716cb1a84872f3eb19c0f0569afbcb9b6e48254a842e7bd755d3f5380bb2dcad3fd1806d65f2029e3a616553602f57cc5c21
7
- data.tar.gz: e11d4046bfa64525f5637f2d695813caf370bb30f57e9faf47c153378c236a242f1cfccbd12b6638a9d4881815203f07cb87357aa5845a58e817af2d20ee381b
6
+ metadata.gz: 55fd92944822e4ed740498c4aff6b91b78cf4c43e053651c972dce7fa064c42d652e5854bcd7def595d1568d8919d65caac6a7b6948703ada90c18280e9bf522
7
+ data.tar.gz: 8c07318ac8507d320d917c37b09c5b378af51e159e489e123f7ff25755bb3843776286fe4de3b764ce09dc9e28d12e7089f7135bcdaea15eb8adefb119e235c2
@@ -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:
@@ -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
- return RPCError.new(r['error']['message'],
42
- r['error']['code'],
43
- r)
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
@@ -17,5 +17,5 @@
17
17
 
18
18
  module Jsonrpctcp
19
19
  # Current gem version
20
- VERSION = "1.0.1"
20
+ VERSION = "1.0.2"
21
21
  end
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.1
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-04 00:00:00.000000000 Z
11
+ date: 2015-06-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler