Skip to content

Commit

Permalink
raise JobFailed if remote server rejects message
Browse files Browse the repository at this point in the history
  • Loading branch information
rekado committed Oct 24, 2014
1 parent 6becbad commit e3e9d27
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions lib/jobs.rb
Expand Up @@ -244,21 +244,19 @@ def self.with_tree(server_id, method_name, *args)
if server.domain.nil? || server.domain.empty?
raise Libertree::JobInvalid, "Server #{server.id} has no domain."
end

begin
params = Request.client.send(method_name, *args)
Request.client.request(server.domain, params)

# TODO: when the response code is not OK the job should
# not be marked as successfully completed. Currently, we
# just ignore the response code from the remote tree,
# which is very unwise. This defect is also present in the
# master branch.

success, response = Request.client.request(server.domain, params)
rescue Timeout::Error => e
raise Libertree::RetryJob, "With #{server.domain}: #{e.message}"
rescue => e
raise Libertree::RetryJob, "Fatal error: with #{server.domain}: #{e.message}"
end

if ! success
raise Libertree::JobFailed, "Rejected by #{server.domain}: #{response}"
end
end
end
end
Expand Down

0 comments on commit e3e9d27

Please sign in to comment.