Exception: E2B::CommandExitError

Inherits:
E2BError
  • Object
show all
Defined in:
lib/e2b/errors.rb

Overview

Error raised when a command exits with non-zero exit code

Instance Attribute Summary collapse

Attributes inherited from E2BError

#headers, #status_code

Instance Method Summary collapse

Constructor Details

#initialize(stdout: "", stderr: "", exit_code: 1, error: nil) ⇒ CommandExitError

Returns a new instance of CommandExitError.

Parameters:

  • stdout (String) (defaults to: "")

    Command stdout

  • stderr (String) (defaults to: "")

    Command stderr

  • exit_code (Integer) (defaults to: 1)

    Process exit code

  • error (String, nil) (defaults to: nil)

    Error message from the process



90
91
92
93
94
95
96
97
98
99
# File 'lib/e2b/errors.rb', line 90

def initialize(stdout: "", stderr: "", exit_code: 1, error: nil)
  @stdout = stdout
  @stderr = stderr
  @exit_code = exit_code
  @command_error = error
  message = "Command exited with code #{exit_code}"
  message += ": #{error}" if error
  message += "\nStderr: #{stderr}" if stderr && !stderr.empty?
  super(message)
end

Instance Attribute Details

#command_errorString? (readonly)

Error message from the process

Returns:

  • (String, nil)

    the current value of command_error



83
84
85
# File 'lib/e2b/errors.rb', line 83

def command_error
  @command_error
end

#exit_codeInteger (readonly)

Process exit code

Returns:

  • (Integer)

    the current value of exit_code



83
84
85
# File 'lib/e2b/errors.rb', line 83

def exit_code
  @exit_code
end

#stderrString (readonly)

Command stderr output

Returns:

  • (String)

    the current value of stderr



83
84
85
# File 'lib/e2b/errors.rb', line 83

def stderr
  @stderr
end

#stdoutString (readonly)

Command stdout output

Returns:

  • (String)

    the current value of stdout



83
84
85
# File 'lib/e2b/errors.rb', line 83

def stdout
  @stdout
end

Instance Method Details

#success?Boolean

Returns:

  • (Boolean)


101
102
103
# File 'lib/e2b/errors.rb', line 101

def success?
  false
end