moneta-api 1.8.0 → 1.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/moneta/api/http_exception.rb +2 -9
- data/lib/moneta/api/runtime_exception.rb +2 -9
- data/lib/moneta/api/service_methods.rb +10 -6
- data/lib/moneta/api/version.rb +1 -1
- data/spec/lib/moneta/api/http_exception_spec.rb +1 -1
- data/spec/lib/moneta/api/runtime_exception_spec.rb +6 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 707c0f3b41b40cb9cd00965f1d619f9a674a329d
|
4
|
+
data.tar.gz: dfa069b11ecddc4ef7d50eae311589e712d0040b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
-
|
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
|
-
"#{
|
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
|
-
|
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 = [ "#{
|
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
|
-
|
195
|
+
details = e.to_hash[:fault]
|
196
196
|
|
197
|
-
|
198
|
-
code =
|
199
|
-
detail =
|
197
|
+
exception = Moneta::Api::RuntimeException.new(details[:faultstring])
|
198
|
+
exception.code = details[:faultcode]
|
199
|
+
exception.detail = details[:detail]
|
200
200
|
|
201
|
-
raise
|
201
|
+
raise exception
|
202
202
|
rescue Savon::HTTPError => e
|
203
203
|
http = e.http
|
204
|
-
|
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
|
data/lib/moneta/api/version.rb
CHANGED
@@ -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(
|
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)
|
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 }
|