my_target_api 1.2.5 → 1.2.6

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
  SHA1:
3
- metadata.gz: 8aa87b552833d6f1475c4025960905ec467e0a8d
4
- data.tar.gz: 6acef00c97854e6cd11bb856aacd88400ce7421b
3
+ metadata.gz: f9f3188adcf480c8c732b25cba9d6ff3ed917e82
4
+ data.tar.gz: b952a49b44aad9f0c8cf0c581c449e06dbc02262
5
5
  SHA512:
6
- metadata.gz: 7c18818f72dcf51df870a006e3d4d31a2fc29b2c82884cee6ec6b7e834a1d3fbb91f8c1c65ba4e0ffc73b88b13b4433a7c54c0583336c591edc965456339b540
7
- data.tar.gz: '009657dfbb067defc829318ace623efb238e638d431b83249ecb73f9867c647e2b991d61aecea162a6419c9220eeaa1e5f338d9d269281d7fbdce64647844269'
6
+ metadata.gz: f0441c39f4b4dd63fc8b4ecf9542024c8575041d2fbee0654323ba5a47e34e298cb346158decb33f76499293a722bf5526cf1fb639d998ba0a9976b47b0868fe
7
+ data.tar.gz: 110e86dc4f466f507d0ec690d705f32183357ce80eba4d8f57e6f9ed560eacef549a4477bc93aad287c007302ef3a5f458c866367cd9513fbbe6de388ee5475d
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- my_target_api (1.2.5)
4
+ my_target_api (1.2.6)
5
5
  json (~> 2.0, >= 2.0.0)
6
6
  rest-client (~> 2.0, >= 2.0.0)
7
7
 
data/README.md CHANGED
@@ -7,7 +7,7 @@
7
7
  Add this line to your application's Gemfile:
8
8
 
9
9
  ```
10
- gem 'my_target_api', '~> 1.2.5'
10
+ gem 'my_target_api', '~> 1.2.6'
11
11
  ```
12
12
 
13
13
  Or install from command line:
@@ -14,7 +14,7 @@ class MyTargetApi
14
14
  def get(url, params = {})
15
15
  log_hash(method: 'Request#get', url: url, params: params)
16
16
 
17
- response = with_exception_handling do
17
+ response = with_exception_handling(params) do
18
18
  RestClient.get(url, headers.merge(query(params)))
19
19
  end
20
20
 
@@ -24,7 +24,7 @@ class MyTargetApi
24
24
  def post(url, params = {})
25
25
  log_hash(method: 'Request#post', url: url, params: params)
26
26
 
27
- response = with_exception_handling do
27
+ response = with_exception_handling(params) do
28
28
  RestClient.post(url, body_parameters(params), headers)
29
29
  end
30
30
 
@@ -34,7 +34,7 @@ class MyTargetApi
34
34
  def delete(url, params = {})
35
35
  log_hash(method: 'Request#delete', url: url, params: params)
36
36
 
37
- response = with_exception_handling do
37
+ response = with_exception_handling(params) do
38
38
  RestClient.delete(url, headers.merge(query(params)))
39
39
  end
40
40
 
@@ -44,7 +44,7 @@ class MyTargetApi
44
44
  def upload(url, content, params = {})
45
45
  log_hash(method: 'Request#upload', url: url, params: params, content: 'no logging')
46
46
 
47
- response = with_exception_handling do
47
+ response = with_exception_handling(params) do
48
48
  RestClient.post(
49
49
  url, content, headers.merge(query(params)).merge(content_type: 'application/octet-stream')
50
50
  )
@@ -90,16 +90,16 @@ class MyTargetApi
90
90
  response.body
91
91
  end
92
92
 
93
- def with_exception_handling
93
+ def with_exception_handling(params)
94
94
  response = yield
95
95
  log(response)
96
96
  response
97
97
  rescue RestClient::ExceptionWithResponse => e
98
98
  log_rest_client_exception(e)
99
- raise MyTargetApi::RequestError, e
99
+ raise_with_params(e, params)
100
100
  rescue RestClient::Exception => e
101
101
  log("#{e.class.name} #{e.message}")
102
- raise MyTargetApi::RequestError, e
102
+ raise_with_params(e, params)
103
103
  rescue SocketError => e
104
104
  raise MyTargetApi::ConnectionError, e
105
105
  end
@@ -113,11 +113,17 @@ class MyTargetApi
113
113
  HTTP Code: #{exception.http_code}
114
114
  HTTP Body: #{exception.http_body}
115
115
  HTTP headers: #{exception.http_headers}
116
- LOG
116
+ LOG
117
117
 
118
118
  log(log_message)
119
119
  end
120
120
 
121
+ def raise_with_params(e, params)
122
+ result = MyTargetApi::RequestError.new(e, params)
123
+ result.set_backtrace(caller)
124
+ raise result
125
+ end
126
+
121
127
  def log_hash(hash)
122
128
  log(hash.map do |key, value|
123
129
  "#{key}: #{value.is_a?(String) ? value : value.inspect}"
@@ -5,9 +5,11 @@ class MyTargetApi
5
5
  class RequestError < StandardError
6
6
 
7
7
  attr_reader :original_exception
8
+ attr_reader :params
8
9
 
9
- def initialize(exception)
10
+ def initialize(exception, params)
10
11
  @original_exception = exception
12
+ @params = params
11
13
  super build_message exception
12
14
  end
13
15
 
@@ -2,6 +2,6 @@
2
2
 
3
3
  class MyTargetApi
4
4
 
5
- VERSION = '1.2.5'
5
+ VERSION = '1.2.6'
6
6
 
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: my_target_api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.5
4
+ version: 1.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - OneRetarget.com
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-02-28 00:00:00.000000000 Z
11
+ date: 2020-07-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: json