shutl_resource 1.2.0 → 1.3.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.
@@ -1,10 +1,8 @@
|
|
1
1
|
class Shutl::Resource::Error < ::IOError
|
2
|
-
attr_reader :
|
2
|
+
attr_reader :body, :status
|
3
3
|
|
4
|
-
def initialize
|
5
|
-
@
|
6
|
-
|
7
|
-
super message #it really is rather spot on, why thanks for saying, kind sir.
|
4
|
+
def initialize body, status
|
5
|
+
@body, @status = body, status
|
8
6
|
end
|
9
7
|
end
|
10
8
|
|
@@ -292,14 +292,16 @@ module Shutl::Resource
|
|
292
292
|
Shutl::ServerError
|
293
293
|
end
|
294
294
|
|
295
|
-
|
296
|
-
|
297
|
-
response.body
|
298
|
-
|
299
|
-
|
295
|
+
if failure_klass
|
296
|
+
body = if response.headers["content-type"] == "application/json"
|
297
|
+
response.body
|
298
|
+
else
|
299
|
+
{debug_info: response.body}
|
300
300
|
end
|
301
301
|
|
302
|
-
|
302
|
+
|
303
|
+
raise failure_klass.new body, response.status
|
304
|
+
end
|
303
305
|
end
|
304
306
|
|
305
307
|
protected
|
data/spec/error_spec.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
describe Shutl::Resource::Error do
|
3
|
+
|
4
|
+
specify "it has a body and status" do
|
5
|
+
error = Shutl::Resource::Error.new({errors: {base: ["something went wrong"]}}, 500)
|
6
|
+
|
7
|
+
error.body.should == {errors: {base: ["something went wrong"]}}
|
8
|
+
error.status.should == 500
|
9
|
+
end
|
10
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: shutl_resource
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-08-
|
14
|
+
date: 2013-08-30 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: httparty
|
@@ -203,6 +203,7 @@ files:
|
|
203
203
|
- spec/configuration_spec.rb
|
204
204
|
- spec/configured_base_uri_spec.rb
|
205
205
|
- spec/dynamic_resource_spec.rb
|
206
|
+
- spec/error_spec.rb
|
206
207
|
- spec/remote_url_spec.rb
|
207
208
|
- spec/rest_resource_spec.rb
|
208
209
|
- spec/spec_helper.rb
|
@@ -221,21 +222,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
221
222
|
- - ! '>='
|
222
223
|
- !ruby/object:Gem::Version
|
223
224
|
version: '0'
|
224
|
-
segments:
|
225
|
-
- 0
|
226
|
-
hash: 4547288023567173599
|
227
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
228
226
|
none: false
|
229
227
|
requirements:
|
230
228
|
- - ! '>='
|
231
229
|
- !ruby/object:Gem::Version
|
232
230
|
version: '0'
|
233
|
-
segments:
|
234
|
-
- 0
|
235
|
-
hash: 4547288023567173599
|
236
231
|
requirements: []
|
237
232
|
rubyforge_project:
|
238
|
-
rubygems_version: 1.8.
|
233
|
+
rubygems_version: 1.8.23
|
239
234
|
signing_key:
|
240
235
|
specification_version: 3
|
241
236
|
summary: Manage Shutl Rest resource. Parse/Serialize JSON
|
@@ -243,6 +238,7 @@ test_files:
|
|
243
238
|
- spec/configuration_spec.rb
|
244
239
|
- spec/configured_base_uri_spec.rb
|
245
240
|
- spec/dynamic_resource_spec.rb
|
241
|
+
- spec/error_spec.rb
|
246
242
|
- spec/remote_url_spec.rb
|
247
243
|
- spec/rest_resource_spec.rb
|
248
244
|
- spec/spec_helper.rb
|