jrpc 0.4.5 → 0.4.6

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: 86859b2a5e5c8e565a8d5e3b5526ccd95b289691
4
- data.tar.gz: 0e15bc4ea87ce5379416b773fb7a17a28098ae51
3
+ metadata.gz: 9d50ab0067ae7afd904f28ddbbea101007a5d0b8
4
+ data.tar.gz: 05b0c1cacb643a91d2f678aa8f0f8b56171b7a26
5
5
  SHA512:
6
- metadata.gz: 2e5d0b057e426defe5f023d43de9acbb162c29dd6c280f0034dd7cd81cbd21fbe7c8bcddfba84d626b772ad583ca20c9f45fe66879398535c8ba7f2ece266f3c
7
- data.tar.gz: a19e8ae5fc621f6578ce8284786fa215f668c1e488845ffdc7707bd6028b6a9728a9975372971863c830d3a9fa9c5af874cdf824186d5285911e78d3400bef60
6
+ metadata.gz: 9d360a93e53d3ae19d31a16297d75a3cb6f35d08fbff9eca0117fa7e426fc426498dc7ae94abbcc5acc18ca99f1e8917ae9353810e6ceb868a697c43a2929827
7
+ data.tar.gz: a50513f654cb83bfaed158e5fe6a7a4e805804440946e86cb29529589635abf389bd7ff3bb924fc2244582b2c0e1d23bdc56651fbbe5649182dc37117e3aec2a
@@ -3,6 +3,7 @@ require 'jrpc/utils'
3
3
  require 'jrpc/base_client'
4
4
  require 'jrpc/tcp_client'
5
5
  require 'jrpc/error/error'
6
+ require 'jrpc/error/connection_error'
6
7
  require 'jrpc/error/client_error'
7
8
  require 'jrpc/error/server_error'
8
9
  require 'jrpc/error/internal_error'
@@ -0,0 +1,11 @@
1
+ module JRPC
2
+ class ConnectionError < Error
3
+ attr_reader :original
4
+
5
+ def initialize(msg, original=$!)
6
+ super(msg)
7
+ @original = original
8
+ end
9
+
10
+ end
11
+ end
@@ -21,6 +21,8 @@ module JRPC
21
21
  connect_timeout: t,
22
22
  read_timeout: t, # write_timeout: t,
23
23
  buffered: false # recommended for RPC
24
+ rescue ::SocketError
25
+ raise ConnectionError, "Can't connect to #{@uri}"
24
26
  end
25
27
 
26
28
  private
@@ -50,6 +52,8 @@ module JRPC
50
52
 
51
53
  def send_request(request)
52
54
  @transport.write Netstring.dump(request.to_s)
55
+ rescue ::SocketError
56
+ raise ConnectionError, "Can't send request to #{uri}"
53
57
  end
54
58
 
55
59
  def receive_response
@@ -57,6 +61,8 @@ module JRPC
57
61
  response = @transport.read(length+1)
58
62
  raise ClientError.new('invalid response. missed comma as terminator') if response[-1] != ','
59
63
  response.chomp(',')
64
+ rescue ::SocketError
65
+ raise ConnectionError, "Can't receive response from #{uri}"
60
66
  end
61
67
 
62
68
  def get_msg_length
@@ -1,3 +1,3 @@
1
1
  module JRPC
2
- VERSION = '0.4.5'
2
+ VERSION = '0.4.6'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jrpc
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.5
4
+ version: 0.4.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Denis Talakevich
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-13 00:00:00.000000000 Z
11
+ date: 2015-12-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: netstring
@@ -118,6 +118,7 @@ files:
118
118
  - lib/jrpc.rb
119
119
  - lib/jrpc/base_client.rb
120
120
  - lib/jrpc/error/client_error.rb
121
+ - lib/jrpc/error/connection_error.rb
121
122
  - lib/jrpc/error/error.rb
122
123
  - lib/jrpc/error/internal_error.rb
123
124
  - lib/jrpc/error/internal_server_error.rb