mirror of
https://github.com/discourse/discourse.git
synced 2026-08-11 05:25:16 -05:00
FIX: Make error in Discourse Hub more descriptive. (#6438)
This commit is contained in:
committed by
Régis Hanol
parent
47f19adac8
commit
1fb1f4c790
+13
-2
@@ -52,14 +52,25 @@ module DiscourseHub
|
||||
|
||||
def self.collection_action(action, rel_url, params = {})
|
||||
connect_opts = connect_opts(params)
|
||||
JSON.parse(Excon.send(action,
|
||||
|
||||
response = Excon.send(action,
|
||||
"#{hub_base_url}#{rel_url}",
|
||||
{
|
||||
body: JSON[params],
|
||||
headers: { 'Referer' => referer, 'Accept' => accepts.join(', '), "Content-Type" => "application/json" },
|
||||
omit_default_port: true
|
||||
}.merge(connect_opts)
|
||||
).body)
|
||||
)
|
||||
|
||||
if response.status != 200
|
||||
Rails.logger.warn("Discourse Hub (#{hub_base_url}#{rel_url}) returned a bad status #{response.status}.")
|
||||
end
|
||||
|
||||
begin
|
||||
JSON.parse(response.body)
|
||||
rescue JSON::ParserError
|
||||
Rails.logger.error("Discourse Hub returned a bad response body: " + response.body)
|
||||
end
|
||||
end
|
||||
|
||||
def self.connect_opts(params = {})
|
||||
|
||||
Reference in New Issue
Block a user