moneta-api 1.8.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4b259ad7ef797550ed047b3c8574a71e52b97f2e
4
- data.tar.gz: ebc37bd7040d7fce6868e23d90704000827a5f7e
3
+ metadata.gz: 707c0f3b41b40cb9cd00965f1d619f9a674a329d
4
+ data.tar.gz: dfa069b11ecddc4ef7d50eae311589e712d0040b
5
5
  SHA512:
6
- metadata.gz: d3a331bb23264266da8355fac205bb0287b253e84e6e03a1dd1e9134a433db26bd6d9557814d6c56e55e5b824a625794fa861f2729284133300163474b111a07
7
- data.tar.gz: fe34ca732de7d0a369e3637ad99574d3c0efda9de2229a4145e6162342089276cc6ff7fe4bc6cf3cf7e0b4603b1383c7587d21a10e289f03df65409862cc5414
6
+ metadata.gz: 229958ad7ddb8837d51b0cde673a075f42a40befeabb55f6efb1c28cad8a3bc1444f76573e654034eec45888e74d5293875966c3155ec0752e2f7c471925e0dd
7
+ data.tar.gz: c6e3d3f19827dfd8a3f2e9ab3101a07dc3bb61c44e61912795eb7bf67529251f9966b5bd4ae60e7436f5d8e1602ab43355eaf9b88a880662b71e95c62ef635af
@@ -1,17 +1,10 @@
1
1
  module Moneta
2
2
  module Api
3
3
  class HTTPException < Exception
4
- attr_reader :code
5
-
6
- def initialize(code, message)
7
- super(message)
8
-
9
- @code = code
10
- end
11
-
4
+ attr_accessor :code
12
5
 
13
6
  def inspect
14
- "#{ @code }: #{ message }"
7
+ "#{ code }: #{ message }"
15
8
  end
16
9
 
17
10
  def to_hash
@@ -1,17 +1,10 @@
1
1
  module Moneta
2
2
  module Api
3
3
  class RuntimeException < Exception
4
- attr_reader :code, :detail
5
-
6
- def initialize(code, message, detail)
7
- super(message)
8
-
9
- @code = code
10
- @detail = detail
11
- end
4
+ attr_accessor :code, :detail
12
5
 
13
6
  def inspect
14
- error = [ "#{ @code }: #{ message }" ]
7
+ error = [ "#{ code }: #{ message }" ]
15
8
  error += detail.collect { |key, value| "#{ key }: #{ Array(value).join($/) }" }
16
9
  error.join($/)
17
10
  end
@@ -192,16 +192,20 @@ module Moneta
192
192
 
193
193
  ResponseFactory.build(response)
194
194
  rescue Savon::SOAPFault => e
195
- error_details = e.to_hash[:fault]
195
+ details = e.to_hash[:fault]
196
196
 
197
- message = error_details[:faultstring]
198
- code = error_details[:faultcode]
199
- detail = error_details[:detail]
197
+ exception = Moneta::Api::RuntimeException.new(details[:faultstring])
198
+ exception.code = details[:faultcode]
199
+ exception.detail = details[:detail]
200
200
 
201
- raise Moneta::Api::RuntimeException.new(code, message, detail)
201
+ raise exception
202
202
  rescue Savon::HTTPError => e
203
203
  http = e.http
204
- raise Moneta::Api::HTTPException.new(http.code, http.body)
204
+
205
+ exception = Moneta::Api::HTTPException.new(http.body)
206
+ exception.code = http.code
207
+
208
+ raise exception
205
209
  rescue HTTPI::Error => e
206
210
  raise Moneta::Api::ConnectionException.new(e.message)
207
211
  end
@@ -1,5 +1,5 @@
1
1
  module Moneta
2
2
  module Api
3
- VERSION = '1.8.0'
3
+ VERSION = '1.9.0'
4
4
  end
5
5
  end
@@ -2,7 +2,7 @@ describe Moneta::Api::HTTPException do
2
2
  let(:message) { 'Server Error' }
3
3
  let(:code) { '500' }
4
4
 
5
- let(:exception) { described_class.new(code, message) }
5
+ let(:exception) { described_class.new(message).tap { |e| e.code = code } }
6
6
 
7
7
  describe '.to_hash' do
8
8
  subject { exception.to_hash }
@@ -3,7 +3,12 @@ describe Moneta::Api::RuntimeException do
3
3
  let(:code) { 'SOAP-ENV:Client' }
4
4
  let(:detail) { { foo: ['bar'] } }
5
5
 
6
- let(:exception) { described_class.new(code, message, detail) }
6
+ let(:exception) do
7
+ described_class.new(message).tap do |e|
8
+ e.code = code
9
+ e.detail = detail
10
+ end
11
+ end
7
12
 
8
13
  describe '.to_hash' do
9
14
  subject { exception.to_hash }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: moneta-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.0
4
+ version: 1.9.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ssnikolay