Move error handling to else branch in execute_command

This commit is contained in:
Sebastian Serth
2021-10-17 23:36:50 +02:00
parent 95f97bd66e
commit a6a477e361

View File

@ -139,16 +139,13 @@ class Runner::Strategy::Poseidon < Runner::Strategy
when 200 when 200
response_body = self.class.parse response response_body = self.class.parse response
websocket_url = response_body[:websocketUrl] websocket_url = response_body[:websocketUrl]
if websocket_url.present? websocket_url.presence || raise(Runner::Error::UnexpectedResponse.new('Poseidon did not send a WebSocket URL'))
return websocket_url
else
raise Runner::Error::UnexpectedResponse.new('Poseidon did not send a WebSocket URL')
end
when 400 when 400
Runner.destroy(@allocation_id) Runner.destroy(@allocation_id)
end
self.class.handle_error response self.class.handle_error response
else
self.class.handle_error response
end
rescue Faraday::Error => e rescue Faraday::Error => e
raise Runner::Error::FaradayError.new("Request to Poseidon failed: #{e.inspect}") raise Runner::Error::FaradayError.new("Request to Poseidon failed: #{e.inspect}")
end end