Skip to content

Commit 8986a96

Browse files
author
Ron Dahlgren
committed
Pass decoder through to error object
1 parent 8b798fa commit 8986a96

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/serpapi/client.rb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def process_json_response(response, endpoint, params)
254254
end
255255

256256
def process_html_response(response, endpoint, params)
257-
raise_http_error(response, nil, endpoint, params) if response.status != 200
257+
raise_http_error(response, nil, endpoint, params, decoder: :html) if response.status != 200
258258
response.body
259259
end
260260

@@ -269,7 +269,7 @@ def validate_json_content!(data, response, endpoint, params)
269269
end
270270

271271
# Centralized error raising to clean up the logic methods
272-
def raise_http_error(response, data, endpoint, params, explicit_error: nil)
272+
def raise_http_error(response, data, endpoint, params, explicit_error: nil, decoder: :json)
273273
msg = "HTTP request failed with status: #{response.status}"
274274
msg += " error: #{explicit_error}" if explicit_error
275275

@@ -279,7 +279,7 @@ def raise_http_error(response, data, endpoint, params, explicit_error: nil)
279279
search_params: params,
280280
response_status: response.status,
281281
search_id: data&.dig(:search_metadata, :id),
282-
decoder: :json # Assuming JSON based on context of use in original code
282+
decoder: decoder
283283
)
284284
end
285285

0 commit comments

Comments
 (0)