Exception: ShellException

Inherits:
CeedlingException show all
Defined in:
lib/ceedling/exceptions.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(shell_result: {}, name:, message: '') ⇒ ShellException



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/ceedling/exceptions.rb', line 20

def initialize(shell_result:{}, name:, message:'')
  @shell_result = shell_result

  _message = ''
  
  # Most shell exceptions will be from build compilation and linking.
  # The formatting of these messages should place the tool output on its own
  # lines without any other surrounding characters.
  # This formatting maximizes the ability of IDEs to parse, highlight, and make 
  # actionable the build errors that appear within their terminal windows.

  # If shell results exist, report the exit code...
  if !shell_result.empty?
    _message = "#{name} terminated with exit code [#{shell_result[:exit_code]}]"

    if !shell_result[:output].empty?
      _message += " and output >>\n#{shell_result[:output].strip()}"
    end

  # Otherwise, just report the exception message
  else
    _message = "#{name} encountered an error with output >>\n#{message}"
  end

  # Hand the message off to parent Exception
  super( _message )
end

Instance Attribute Details

#shell_resultObject (readonly)

Returns the value of attribute shell_result.



18
19
20
# File 'lib/ceedling/exceptions.rb', line 18

def shell_result
  @shell_result
end