Exception: Autobuild::SubcommandFailed

Inherits:
PhaseException show all
Defined in:
lib/autobuild/exceptions.rb

Overview

An error occured while running a subcommand

Instance Attribute Summary collapse

Attributes inherited from PhaseException

#phase, #target

Instance Method Summary collapse

Methods inherited from PhaseException

#exception_message, #fatal?, #retry?

Constructor Details

#initialize(*args) ⇒ SubcommandFailed

Returns a new instance of SubcommandFailed.



92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
# File 'lib/autobuild/exceptions.rb', line 92

def initialize(*args)
    case args.size
    when 1
        sc = args[0]
        target = sc.target
        command = sc.command
        logfile = sc.logfile
        status = sc.status
        output = sc.output
        @orig_message = sc.exception_message
    when 4, 5
        target, command, logfile, status, output = *args
    else
        raise ArgumentError, "wrong number of arguments, should be 1 or 4..5"
    end

    super(target)
    @command = command
    @logfile = logfile
    @status  = status
    @output = output || Array.new
end

Instance Attribute Details

#commandObject (readonly)

Returns the value of attribute command.



90
91
92
# File 'lib/autobuild/exceptions.rb', line 90

def command
  @command
end

#logfileObject (readonly)

Returns the value of attribute logfile.



90
91
92
# File 'lib/autobuild/exceptions.rb', line 90

def logfile
  @logfile
end

#outputObject (readonly)

Returns the value of attribute output.



90
91
92
# File 'lib/autobuild/exceptions.rb', line 90

def output
  @output
end

#retry=(value) ⇒ Object (writeonly)

Sets the attribute retry

Parameters:

  • value

    the value to set the attribute retry to.



89
90
91
# File 'lib/autobuild/exceptions.rb', line 89

def retry=(value)
  @retry = value
end

#statusObject (readonly)

Returns the value of attribute status.



90
91
92
# File 'lib/autobuild/exceptions.rb', line 90

def status
  @status
end

Instance Method Details

#mail?Boolean

Returns:

  • (Boolean)


85
86
87
# File 'lib/autobuild/exceptions.rb', line 85

def mail?
    true
end

#to_sObject



115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
# File 'lib/autobuild/exceptions.rb', line 115

def to_s
    msg = super
    msg << "\n     #{@orig_message}" if @orig_message
    msg << "\n    see #{logfile} for details"

    # If we do not have a status, it means an error occured in the
    # launching process. More importantly, it means we already have a
    # proper explanation for it. Don't display the logfile at all.
    if status
        lines = @output
        logsize = Autobuild.displayed_error_line_count
        if logsize != Float::INFINITY && lines.size > logsize
            lines = lines[-logsize, logsize]
        end
        msg << "\n    last #{lines.size} lines are:\n\n"
        lines.each do |l|
            msg << "    #{l}\n"
        end
    end
    msg
end