From f9288741896c1a401954c62326c84c20022ba41f Mon Sep 17 00:00:00 2001 From: Ralf Teusner Date: Wed, 16 Dec 2015 16:30:54 +0100 Subject: [PATCH] directly call proc (before execution block) and rescue from an exception if it happens instead of using try, in order to log the error. --- lib/docker_client.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/docker_client.rb b/lib/docker_client.rb index 754b2458..4ac5836d 100644 --- a/lib/docker_client.rb +++ b/lib/docker_client.rb @@ -168,7 +168,13 @@ class DockerClient @container = DockerContainerPool.get_container(@execution_environment) if @container @container.status = :executing - before_execution_block.try(:call) + # do not use try here, directly call the passed proc and rescue from the error in order to log the problem. + #before_execution_block.try(:call) + begin + before_execution_block.call + rescue StandardError => error + Rails.logger.error('execute_websocket_command: Rescued from StandardError caused by before_execution_block.call: ' + error.to_s) + end # TODO: catch exception if socket could not be created @socket ||= create_socket(@container) # Newline required to flush