diff --git a/lib/barbeque/message_handler/job_execution.rb b/lib/barbeque/message_handler/job_execution.rb index 28125cf..8183302 100644 --- a/lib/barbeque/message_handler/job_execution.rb +++ b/lib/barbeque/message_handler/job_execution.rb @@ -25,7 +25,7 @@ def run stdout, stderr, status = Executor.create.run(job_execution, job_envs) rescue Exception => e job_execution.update!(status: :error, finished_at: Time.now) - Barbeque::ExecutionLog.save_stdout_and_stderr(job_execution, '', '') + Barbeque::ExecutionLog.save_stdout_and_stderr(job_execution, '', "#{e.class}: #{e.message}\n#{e.backtrace.join("\n")}") Barbeque::SlackNotifier.notify_job_execution(job_execution) raise e end diff --git a/lib/barbeque/message_handler/job_retry.rb b/lib/barbeque/message_handler/job_retry.rb index 056e7eb..fb43c9b 100644 --- a/lib/barbeque/message_handler/job_retry.rb +++ b/lib/barbeque/message_handler/job_retry.rb @@ -28,7 +28,7 @@ def run rescue Exception => e job_retry.update!(status: :error, finished_at: Time.now) job_execution.update!(status: :error) - Barbeque::ExecutionLog.save_stdout_and_stderr(job_retry, '', '') + Barbeque::ExecutionLog.save_stdout_and_stderr(job_retry, '', "#{e.class}: #{e.message}\n#{e.backtrace.join("\n")}") Barbeque::SlackNotifier.notify_job_retry(job_retry) raise e end diff --git a/spec/barbeque/message_handler/job_execution_spec.rb b/spec/barbeque/message_handler/job_execution_spec.rb index 896065f..7738101 100644 --- a/spec/barbeque/message_handler/job_execution_spec.rb +++ b/spec/barbeque/message_handler/job_execution_spec.rb @@ -139,7 +139,7 @@ let(:exception) { Class.new(StandardError) } before do - expect(executor).to receive(:run).and_raise(exception) + expect(executor).to receive(:run).and_raise(exception.new('something went wrong')) end it 'updates status to error' do @@ -150,7 +150,7 @@ it 'logs message body' do expect(Barbeque::ExecutionLog).to receive(:save_message).with(a_kind_of(Barbeque::JobExecution), message) - expect(Barbeque::ExecutionLog).to receive(:save_stdout_and_stderr).with(a_kind_of(Barbeque::JobExecution), '', '') + expect(Barbeque::ExecutionLog).to receive(:save_stdout_and_stderr).with(a_kind_of(Barbeque::JobExecution), '', /something went wrong/) expect { handler.run }.to raise_error(exception) end end diff --git a/spec/barbeque/message_handler/job_retry_spec.rb b/spec/barbeque/message_handler/job_retry_spec.rb index 5780bb4..442c69c 100644 --- a/spec/barbeque/message_handler/job_retry_spec.rb +++ b/spec/barbeque/message_handler/job_retry_spec.rb @@ -154,7 +154,7 @@ let(:exception) { Class.new(StandardError) } before do - expect(executor).to receive(:run).and_raise(exception) + expect(executor).to receive(:run).and_raise(exception.new('something went wrong')) end it 'updates status to error' do @@ -166,7 +166,7 @@ end it 'logs empty output' do - expect(Barbeque::ExecutionLog).to receive(:save_stdout_and_stderr).with(a_kind_of(Barbeque::JobRetry), '', '') + expect(Barbeque::ExecutionLog).to receive(:save_stdout_and_stderr).with(a_kind_of(Barbeque::JobRetry), '', /something went wrong/) expect { handler.run }.to raise_error(exception) end end