From a6a477e3616930939c95d1dc495627712435dfbe Mon Sep 17 00:00:00 2001 From: Sebastian Serth Date: Sun, 17 Oct 2021 23:36:50 +0200 Subject: [PATCH] Move error handling to else branch in execute_command --- lib/runner/strategy/poseidon.rb | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/runner/strategy/poseidon.rb b/lib/runner/strategy/poseidon.rb index 10ce2a60..1c8ed3b9 100644 --- a/lib/runner/strategy/poseidon.rb +++ b/lib/runner/strategy/poseidon.rb @@ -139,16 +139,13 @@ class Runner::Strategy::Poseidon < Runner::Strategy when 200 response_body = self.class.parse response websocket_url = response_body[:websocketUrl] - if websocket_url.present? - return websocket_url - else - raise Runner::Error::UnexpectedResponse.new('Poseidon did not send a WebSocket URL') - end + websocket_url.presence || raise(Runner::Error::UnexpectedResponse.new('Poseidon did not send a WebSocket URL')) when 400 Runner.destroy(@allocation_id) + self.class.handle_error response + else + self.class.handle_error response end - - self.class.handle_error response rescue Faraday::Error => e raise Runner::Error::FaradayError.new("Request to Poseidon failed: #{e.inspect}") end