diff --git a/src/containers/ftp/ftp.rb b/src/containers/ftp/ftp.rb index e0cd14f..4b4439f 100755 --- a/src/containers/ftp/ftp.rb +++ b/src/containers/ftp/ftp.rb @@ -112,13 +112,12 @@ output: task_result.to_json }) rescue => e - puts e.class.name - puts e.message puts e.backtrace logger.debug(JSON.dump({ - msg: "Copying state machine results file for error", - bucket_name: bucket, + msg: "Sending task failure", + error: e.class.name, + message: e.message, object_key: RESULT_KEY })) sf.send_task_failure({ diff --git a/src/containers/transcode/transcode.rb b/src/containers/transcode/transcode.rb index 92b4a1a..632e99d 100644 --- a/src/containers/transcode/transcode.rb +++ b/src/containers/transcode/transcode.rb @@ -101,7 +101,8 @@ def underscore puts "Calling FFmpeg" puts ffmpeg_cmd - raise StandardError, "FFmpeg failed" unless system ffmpeg_cmd + _ff_stdout, ff_stderr, ff_status = Open3.capture3(ffmpeg_cmd) + raise StandardError, "FFmpeg failed" unless ff_status.success? end_time = Time.now.to_i duration = end_time - start_time @@ -116,11 +117,11 @@ def underscore "-print_format json" ].join(" ") - stdout, _stderr, status = Open3.capture3(ffprobe_cmd) - raise StandardError, "FFmpeg probe failed" unless status.success? + probe_stdout, probe_stderr, probe_status = Open3.capture3(ffprobe_cmd) + raise StandardError, "FFmpeg probe failed" unless probe_status.success? # Add the probe results for this output to the task result - probe_results = JSON.parse(stdout) + probe_results = JSON.parse(probe_stdout) task_result[:Duration] = probe_results["format"]["duration"].to_f * 1000 task_result[:Size] = probe_results["format"]["size"].to_i @@ -229,9 +230,11 @@ def underscore rescue => e puts JSON.dump({msg: "Task failed!", error: e.class.name, cause: e.message}) puts e.backtrace + p ff_stderr + p probe_stderr sf.send_task_failure({ task_token: ENV["STATE_MACHINE_TASK_TOKEN"], error: e.class.name, - cause: e.message + cause: [e.message, ff_stderr, probe_stderr].compact.join("\n\n") }) end diff --git a/state-machine.asl.yml b/state-machine.asl.yml index d123792..fc63447 100644 --- a/state-machine.asl.yml +++ b/state-machine.asl.yml @@ -695,6 +695,10 @@ States: Id.$: "$.Job.Id" Execution: Id.$: "$$.Execution.Id" + # $.Error will exist when a state takes the Catch path (because + # of `ResultPath: "$.Error"`) and will generally be an object + # like: + # { Error: "SomeError", Cause: "Something went wrong" } Error.$: "$.Error" ResultPath: "$.Void" # The output of the iterator states is discarded OutputPath: "$.Task"