Exception: Omnibus::CommandTimeout

Inherits:
Error
  • Object
show all
Defined in:
lib/omnibus/exceptions.rb

Instance Method Summary collapse

Constructor Details

#initialize(cmd) ⇒ CommandTimeout

Returns a new instance of CommandTimeout.



278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/omnibus/exceptions.rb', line 278

def initialize(cmd)
  status = cmd.exitstatus

  if cmd.environment.nil? || cmd.environment.empty?
    env = nil
  else
    env = cmd.environment.sort.map { |k, v| "#{k}=#{v}" }.join(" ")
  end

  command = cmd.command
  command_with_env = [env, command].compact.join(" ")

  timeout = cmd.timeout.to_s.reverse.gsub(/...(?=.)/, '\&,').reverse

  super <<~EOH
    The following shell command timed out at #{timeout} seconds:

        $ #{command_with_env}

    Please increase the `:timeout' value or run the command manually to make sure it
    is completing successfully. Sometimes it is common for a command to wait for
    user input.
  EOH
end