class TTY::Command::ExitError

An ExitError reports an unsuccessful exit by command.

The error message includes:

* the name of command executed
* the exit status
* stdout bytes
* stderr bytes

@api private

Public Class Methods

new(cmd_name, result) click to toggle source
Calls superclass method
# File lib/tty/command/exit_error.rb, line 15
def initialize(cmd_name, result)
  super(info(cmd_name, result))
end

Public Instance Methods

extract_output(value) click to toggle source
# File lib/tty/command/exit_error.rb, line 26
def extract_output(value)
  (value || "").strip.empty? ? "Nothing written" : value.strip
end
info(cmd_name, result) click to toggle source
# File lib/tty/command/exit_error.rb, line 19
def info(cmd_name, result)
  "Running `#{cmd_name}` failed with\n" \
  "  exit status: #{result.exit_status}\n" \
  "  stdout: #{extract_output(result.out)}\n" \
  "  stderr: #{extract_output(result.err)}\n"
end