msgpack-rpc-stack 0.6.2 → 0.6.3

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
  SHA256:
3
- metadata.gz: 1a0fc541f88109eea1fadf77aab899056ed65158fce6bf01be96d4d74c4ad326
4
- data.tar.gz: f0f52e6611f45b7070326d79e9bd36b3fc03afb611c58cc409296ae33353be70
3
+ metadata.gz: dcca66fedc4f14b5def751157fef92927c9eb1cda24e79f72659ca79afc5898d
4
+ data.tar.gz: 8ac3ded467f2235be2e4c982ff5f11badfb0748ac952b9d9244d4e87fe70ea9a
5
5
  SHA512:
6
- metadata.gz: 285913a29d7fa67e05e2f562c254c179ade7918ebd015161520ae6e92c677d0a7e6750c883aca236f9f448346dbacfcb1760ae71574d73fea91e0e177fdd8fbe
7
- data.tar.gz: 7c562c019615657190ee9525a439b53442b33a7214547466272e55c438dadc631fb9c9aa73a5279b637767e7774987986fad758b87829812e8fe96c2249678f0
6
+ metadata.gz: 73af4f48c0178177784087a0afab26d8358c7d37b6752fa8005ef639fc39c4081a7e8956eaef9457b33ed888c0c8cb2e7aa72896123c5e123ab9ead118b369bc
7
+ data.tar.gz: c9180d58dced21f8b88d9b7b852049f419738d0757be35b8bd4c6c26b56ee70a86cf83e16871fe5817b93c121d82ee55fcdbf7a2e367cc3f348b0a78973a44d5
@@ -56,6 +56,17 @@ module MessagePack
56
56
  end
57
57
  private :unpacker
58
58
 
59
+ def error_occured(e)
60
+ e = ProtocolError.new(m) if e.kind_of?(String)
61
+
62
+ if self.respond_to?(:on_error, true)
63
+ __send__(:on_error, e)
64
+ else
65
+ STDERR.print("#{e.message}")
66
+ end
67
+ end
68
+ private :error_occured
69
+
59
70
  def call(meth, *args, &blk)
60
71
  raise ArgumentError.new("handler is not spcified") if not blk
61
72
 
@@ -71,7 +82,7 @@ module MessagePack
71
82
 
72
83
  def eval_response(resp)
73
84
  if not resp.kind_of?(Array)
74
- raise ProtocolError.new("responce is not array")
85
+ error_occured("responce is not array")
75
86
  end
76
87
 
77
88
  case resp.shift
@@ -79,10 +90,9 @@ module MessagePack
79
90
  id, error, result = resp
80
91
 
81
92
  if not session_map.include?(id)
82
- raise ProtocolError.new("unknwon responce id is received.")
83
- end
93
+ error_occured("unknwon responce id is received.")
84
94
 
85
- if error.nil?
95
+ elsif error.nil?
86
96
  # when success
87
97
  session_map.delete(id).(result, nil)
88
98
 
@@ -91,21 +101,22 @@ module MessagePack
91
101
  session_map.delete(id).(nil, error)
92
102
 
93
103
  else
94
- raise ProtocolError.new("unknwon responce id is received.")
104
+ error_occured("unknwon responce id is received.")
95
105
  end
96
106
 
97
107
  when 2 # as notification
98
- meth = resp.shift.to_sym
108
+ meth = resp[0].to_sym
109
+ args = resp[1]
99
110
 
100
111
  if notify_handler.include?(meth)
101
- notify_handler[meth].(*resp)
112
+ notify_handler[meth].(*args)
102
113
 
103
114
  else
104
115
  STDERR.print("unhandled notification '#{meth}' received.\n")
105
116
  end
106
117
 
107
118
  else
108
- raise ProtocolError.new("unknown response received")
119
+ error_occured("unknown response received")
109
120
  end
110
121
  end
111
122
  private :eval_response
@@ -120,10 +131,10 @@ module MessagePack
120
131
 
121
132
  rescue MessagePack::UnpackError => e
122
133
  unpacker.reset
123
- raise(e)
134
+ error_occured(e)
124
135
 
125
136
  rescue => e
126
- raise(e)
137
+ error_occured(e)
127
138
  end
128
139
  end
129
140
 
@@ -205,7 +205,7 @@ module MessagePack
205
205
  msg = MessagePack.unpack(data, self.class.msgpack_options)
206
206
 
207
207
  if not msg.kind_of?(Array)
208
- error_occured("not array message is received")
208
+ error_occured(RantimeError.new("not array message is received"))
209
209
  end
210
210
 
211
211
  eval_message(msg)
@@ -1,5 +1,5 @@
1
1
  module MessagePack
2
2
  module Rpc
3
- VERSION = "0.6.2"
3
+ VERSION = "0.6.3"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: msgpack-rpc-stack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hiroshi Kuwagata
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-02-08 00:00:00.000000000 Z
11
+ date: 2019-03-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -94,8 +94,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
96
  requirements: []
97
- rubyforge_project:
98
- rubygems_version: 2.7.6
97
+ rubygems_version: 3.0.1
99
98
  signing_key:
100
99
  specification_version: 4
101
100
  summary: MessagePack-RPC module