algolia 3.8.1 → 3.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/algolia/error.rb +3 -3
- data/lib/algolia/transport/http/http_requester.rb +12 -2
- data/lib/algolia/transport/http/response.rb +3 -1
- data/lib/algolia/transport/transport.rb +5 -0
- data/lib/algolia/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bbf3a0681721633040ecb0140b17558a30960ea7269bc92b811ee7e3061b0c01
|
4
|
+
data.tar.gz: a6192d821fed7c69849d2c0464235d3c83bf47377ac94d270a459e96849033d8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bfcf91d318232cffaa4af72e6979cb0fd561d4c299c25e497a17c54809749249c787d4741803d43435dbb7362ea16cfd45c8a5c240ae981d9f0e8607ed784cf
|
7
|
+
data.tar.gz: 29b4a760a9a5ae9d6f409cada459e5db1e69e219590aef04ad9ca1e0069578660cb841ee6980c41b1ad086c208f0b6a79f82c07e206dad6e307af02a3028298f
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,7 @@
|
|
1
|
+
## [3.8.2](https://github.com/algolia/algoliasearch-client-ruby/compare/3.8.1...3.8.2)
|
2
|
+
|
3
|
+
- [f97e44ce0](https://github.com/algolia/api-clients-automation/commit/f97e44ce0) fix(cts): add tests for HTML error ([#4097](https://github.com/algolia/api-clients-automation/pull/4097)) by [@millotp](https://github.com/millotp/)
|
4
|
+
|
1
5
|
## [3.8.1](https://github.com/algolia/algoliasearch-client-ruby/compare/3.8.0...3.8.1)
|
2
6
|
|
3
7
|
- [36d583e35](https://github.com/algolia/api-clients-automation/commit/36d583e35) fix(specs): make the searchParams compatible with v4 ([#4108](https://github.com/algolia/api-clients-automation/pull/4108)) by [@millotp](https://github.com/millotp/)
|
data/Gemfile.lock
CHANGED
data/lib/algolia/error.rb
CHANGED
@@ -27,12 +27,12 @@ module Algolia
|
|
27
27
|
# which is also included in the response attribute.
|
28
28
|
#
|
29
29
|
class AlgoliaHttpError < AlgoliaError
|
30
|
-
attr_accessor :code, :
|
30
|
+
attr_accessor :code, :http_message
|
31
31
|
|
32
32
|
def initialize(code, message)
|
33
33
|
self.code = code
|
34
|
-
self.
|
35
|
-
super("#{
|
34
|
+
self.http_message = message
|
35
|
+
super("#{code}: #{message}")
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -39,14 +39,24 @@ module Algolia
|
|
39
39
|
@logger.info("Request succeeded. Response status: #{response.status}, body: #{response.body}")
|
40
40
|
end
|
41
41
|
|
42
|
-
return Http::Response.new(
|
42
|
+
return Http::Response.new(
|
43
|
+
status: response.status,
|
44
|
+
reason_phrase: response.reason_phrase,
|
45
|
+
body: response.body,
|
46
|
+
headers: response.headers
|
47
|
+
)
|
43
48
|
end
|
44
49
|
|
45
50
|
if ENV["ALGOLIA_DEBUG"]
|
46
51
|
@logger.info("Request failed. Response status: #{response.status}, error: #{response.body}")
|
47
52
|
end
|
48
53
|
|
49
|
-
Http::Response.new(
|
54
|
+
Http::Response.new(
|
55
|
+
status: response.status,
|
56
|
+
reason_phrase: response.reason_phrase,
|
57
|
+
error: response.body,
|
58
|
+
headers: response.headers
|
59
|
+
)
|
50
60
|
rescue Faraday::TimeoutError => e
|
51
61
|
@logger.info("Request timed out. Error: #{e.message}") if ENV["ALGOLIA_DEBUG"]
|
52
62
|
Http::Response.new(error: e.message, has_timed_out: true)
|
@@ -1,13 +1,14 @@
|
|
1
1
|
module Algolia
|
2
2
|
module Http
|
3
3
|
class Response
|
4
|
-
attr_reader :status, :body, :error, :headers, :has_timed_out, :network_failure
|
4
|
+
attr_reader :status, :reason_phrase, :body, :error, :headers, :has_timed_out, :network_failure
|
5
5
|
|
6
6
|
# used for the echo requester
|
7
7
|
attr_reader :method, :path, :query_params, :host, :timeout, :connect_timeout
|
8
8
|
|
9
9
|
#
|
10
10
|
# @option status [String] Response status
|
11
|
+
# @option reason_phrase [String] Response reason phrase
|
11
12
|
# @option body [String] Response body
|
12
13
|
# @option error [String] Response error or caught error
|
13
14
|
# @option headers [String] Response headers
|
@@ -15,6 +16,7 @@ module Algolia
|
|
15
16
|
#
|
16
17
|
def initialize(opts = {})
|
17
18
|
@status = opts[:status]
|
19
|
+
@reason_phrase = opts[:reason_phrase]
|
18
20
|
@body = opts[:body]
|
19
21
|
@error = opts[:error] || ""
|
20
22
|
@headers = opts[:headers] || ""
|
@@ -69,6 +69,11 @@ module Algolia
|
|
69
69
|
network_failure: response.network_failure
|
70
70
|
)
|
71
71
|
if outcome == FAILURE
|
72
|
+
# handle HTML error
|
73
|
+
if response.headers["content-type"]&.include?("text/html")
|
74
|
+
raise Algolia::AlgoliaHttpError.new(response.status, response.reason_phrase)
|
75
|
+
end
|
76
|
+
|
72
77
|
decoded_error = JSON.parse(response.error, :symbolize_names => true)
|
73
78
|
raise Algolia::AlgoliaHttpError.new(response.status, decoded_error[:message])
|
74
79
|
end
|
data/lib/algolia/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: algolia
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.8.
|
4
|
+
version: 3.8.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- https://alg.li/support
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-11-
|
11
|
+
date: 2024-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: faraday
|