Skip to content

Commit

Permalink
debug: Run: log error level
Browse files Browse the repository at this point in the history
  • Loading branch information
phil294 committed Jul 20, 2023
1 parent c9f78bd commit 6d72f6c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/cmd/misc/run.cr
Original file line number Diff line number Diff line change
Expand Up @@ -115,15 +115,22 @@ class Cmd::Misc::Run < Cmd::Base
thread.runner.set_user_var(output_stderr, stderr) if output_stderr && ! output_stderr.empty?
end

error_level = nil
if opt["useerrorlevel"]?
thread.set_thread_built_in_static_var("ErrorLevel", success ? "0" : "ERROR")
error_level = success ? "0" : "ERROR"
else
if ! success
raise ::Run::RuntimeException.new "Failed attempt to launch program or document: #{target}"
elsif @wait
thread.set_thread_built_in_static_var("ErrorLevel", success.to_s)
error_level = success.to_s
end
end
if error_level
thread.set_thread_built_in_static_var("ErrorLevel", error_level)
{% if ! flag?(:release) %}
puts "[debug] ErrorLevel[#{thread.id}][Run]: #{error_level}"
{% end %}
end

if output_var_pid && ! output_var_pid.empty? && ! @wait && success.is_a?(Int64)
thread.runner.set_user_var(output_var_pid, success.to_s)
Expand Down

0 comments on commit 6d72f6c

Please sign in to comment.