algolia 3.8.1 → 3.8.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c51a14703310430c09094a863959ee54716168cdc77fdb576bcd0f845c38a6d4
4
- data.tar.gz: 64a6763014cc2d405856a8626bcd044e130160255e5c17c7fbd6cc41909418a1
3
+ metadata.gz: bbf3a0681721633040ecb0140b17558a30960ea7269bc92b811ee7e3061b0c01
4
+ data.tar.gz: a6192d821fed7c69849d2c0464235d3c83bf47377ac94d270a459e96849033d8
5
5
  SHA512:
6
- metadata.gz: 1866d02c45e8b6399a1a616ba4f3b918db7be3f6b0b526ebcf97316bcdd11beefca56201ec73024af740bb526ad13e39354e199771550df1ae672c1d6e24f332
7
- data.tar.gz: a8aa53de27a0ba088fa4e1ba725e21b631a6a70f136287772f6e887d29d10140df3c5d2e588d586b4d9f9d03dfbc59a79b3e113c4569706588ee3885a1f5e5c0
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
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- algolia (3.8.1)
4
+ algolia (3.8.2)
5
5
  base64 (>= 0.2.0, < 1)
6
6
  faraday (>= 1.0.1, < 3.0)
7
7
  faraday-net_http_persistent (>= 0.15, < 3)
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, :message
30
+ attr_accessor :code, :http_message
31
31
 
32
32
  def initialize(code, message)
33
33
  self.code = code
34
- self.message = message
35
- super("#{self.code()}: #{self.message()}")
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(status: response.status, body: response.body, headers: response.headers)
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(status: response.status, error: response.body, headers: response.headers)
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
@@ -1,5 +1,5 @@
1
1
  # Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT.
2
2
 
3
3
  module Algolia
4
- VERSION = "3.8.1".freeze
4
+ VERSION = "3.8.2".freeze
5
5
  end
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.1
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-15 00:00:00.000000000 Z
11
+ date: 2024-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: faraday