Sha256: 233aee50ba842bce18b2c72702ff874c24a80801b96603676ede5876f8084ac8

Contents?: true

Size: 826 Bytes

Versions: 7

Compression:

Stored size: 826 Bytes

Contents

# encoding: utf-8

module TTY
  class Command
    # 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
    class ExitError < RuntimeError
      def initialize(cmd_name, result)
        super(info(cmd_name, result))
      end

      def info(cmd_name, result)
        message = ''
        message << "Running `#{cmd_name}` failed with\n"
        message << "  exit status: #{result.exit_status}\n"
        message << "  stdout: #{result.out.strip.empty? ? 'Nothing written' : result.out.strip}\n"
        message << "  stderr: #{result.err.strip.empty? ? 'Nothing written' : result.err.strip}\n"
      end
    end # ExitError
  end # Command
end # TTY

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
tty-command-0.4.0 lib/tty/command/exit_error.rb
tty-command-0.3.3 lib/tty/command/exit_error.rb
tty-command-0.3.2 lib/tty/command/exit_error.rb
tty-command-0.3.1 lib/tty/command/exit_error.rb
tty-command-0.3.0 lib/tty/command/exit_error.rb
tty-command-0.2.0 lib/tty/command/exit_error.rb
tty-command-0.1.0 lib/tty/command/exit_error.rb