Exception: ErrorDuringExecution
- Inherits:
-
RuntimeError
- Object
- RuntimeError
- ErrorDuringExecution
- Defined in:
- Library/Homebrew/exceptions.rb
Overview
Raised by Kernel#safe_system in utils.rb
.
Instance Attribute Summary collapse
-
#cmd ⇒ Object
readonly
Returns the value of attribute cmd.
-
#output ⇒ Object
readonly
Returns the value of attribute output.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
Instance Method Summary collapse
-
#initialize(cmd, status:, output: nil, secrets: []) ⇒ ErrorDuringExecution
constructor
A new instance of ErrorDuringExecution.
- #stderr ⇒ Object
Constructor Details
#initialize(cmd, status:, output: nil, secrets: []) ⇒ ErrorDuringExecution
Returns a new instance of ErrorDuringExecution.
554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 |
# File 'Library/Homebrew/exceptions.rb', line 554 def initialize(cmd, status:, output: nil, secrets: []) @cmd = cmd @status = status @output = output exitstatus = if status.respond_to?(:exitstatus) status.exitstatus else status end redacted_cmd = redact_secrets(cmd.shelljoin.gsub('\=', "="), secrets) s = +"Failure while executing; `#{redacted_cmd}` exited with #{exitstatus}." if Array(output).present? format_output_line = lambda do |type_line| type, line = *type_line if type == :stderr Formatter.error(line) else line end end s << " Here's the output:\n" s << output.map(&format_output_line).join s << "\n" unless s.end_with?("\n") end super s.freeze end |
Instance Attribute Details
#cmd ⇒ Object (readonly)
Returns the value of attribute cmd
552 553 554 |
# File 'Library/Homebrew/exceptions.rb', line 552 def cmd @cmd end |
#output ⇒ Object (readonly)
Returns the value of attribute output
552 553 554 |
# File 'Library/Homebrew/exceptions.rb', line 552 def output @output end |
#status ⇒ Object (readonly)
Returns the value of attribute status
552 553 554 |
# File 'Library/Homebrew/exceptions.rb', line 552 def status @status end |
Instance Method Details
#stderr ⇒ Object
586 587 588 |
# File 'Library/Homebrew/exceptions.rb', line 586 def stderr Array(output).select { |type,| type == :stderr }.map(&:last).join end |