ibm-watson-ruby 0.1.1 → 0.1.2
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 +4 -4
- data/lib/ibm_watson/base_service.rb +12 -6
- data/lib/ibm_watson/errors.rb +1 -0
- data/lib/ibm_watson/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 15892bc1e215dd42b242c92c2bf0a5d839a1baa5
|
4
|
+
data.tar.gz: 14373e54c5085c21b72b487349efa0e523cdb36a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2a5ca379e49f61e6370dd72d5f1653d067dc42835e2022c4234cda18192b853bf97e5f5e8f077053dc2e0d242959a19789b30f7513d328323ab180885fd1fed
|
7
|
+
data.tar.gz: a80c6431fb249a96d381699c2421de76436514fccf670e7859eb557ee4f30c29a3a429eb3936120105e0011ce1a9af67a9d0a46562540bfe1f831a6abf686daa
|
@@ -52,12 +52,18 @@ module IBMWatson
|
|
52
52
|
verify_no_json_failure(result)
|
53
53
|
end
|
54
54
|
elsif result.status.between?(400, 499)
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
55
|
+
generic_error_handler(IBMWatson::Errors::WatsonRequestError, result)
|
56
|
+
elsif result.status.between?(500, 599)
|
57
|
+
generic_error_handler(IBMWatson::Errors::WatsonServerError, result)
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
def generic_error_handler(erorr_klass, result)
|
62
|
+
if result.content_type.mime_type == 'application/json'
|
63
|
+
json_data = JSON.parse(result.body)
|
64
|
+
raise erorr_klass, "Server returned #{result.status} : #{json_data['error']}"
|
65
|
+
else
|
66
|
+
raise erorr_klass, "Server returned #{result.status} : #{result.reason}"
|
61
67
|
end
|
62
68
|
end
|
63
69
|
|
data/lib/ibm_watson/errors.rb
CHANGED
data/lib/ibm_watson/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ibm-watson-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bram Whillock
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-
|
11
|
+
date: 2017-04-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http
|
@@ -185,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
185
|
version: '0'
|
186
186
|
requirements: []
|
187
187
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.5.
|
188
|
+
rubygems_version: 2.5.1
|
189
189
|
signing_key:
|
190
190
|
specification_version: 4
|
191
191
|
summary: IBM Watson services in ruby
|