Exception: Subprocess::NonZeroExit

Inherits:
StandardError
  • Object
show all
Defined in:
lib/subprocess.rb

Overview

Error class representing a process's abnormal exit.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(cmd, status) ⇒ NonZeroExit

Return an instance of Subprocess::NonZeroExit.

Parameters:

  • cmd (Array<String>)

    The command that returned a non-zero status.

  • status (::Process::Status)

    The status returned by waitpid.



170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/subprocess.rb', line 170

def initialize(cmd, status)
  @command, @status = cmd.join(' '), status
  message = "Command #{command} "
  if status.exited?
    message << "returned non-zero exit status #{status.exitstatus}"
  elsif status.signaled?
    message << "was terminated by signal #{status.termsig}"
  elsif status.stopped?
    message << "was stopped by signal #{status.stopsig}"
  else
    message << "exited for an unknown reason (FIXME)"
  end
  super(message)
end

Instance Attribute Details

#commandString (readonly)

Note:

This is intended only for use in user-facing error messages. In particular, no shell quoting of any sort is performed when constructing this string, meaning that blindly running it in a shell might have different semantics than the original command.

Returns The command and arguments for the process that exited abnormally.

Returns:

  • (String)

    The command and arguments for the process that exited abnormally.



161
162
163
# File 'lib/subprocess.rb', line 161

def command
  @command
end

#status::Process::Status (readonly)

Returns The Ruby status object returned by waitpid.

Returns:

  • (::Process::Status)

    The Ruby status object returned by waitpid



164
165
166
# File 'lib/subprocess.rb', line 164

def status
  @status
end