Exception: Omnibus::CommandTimeout

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

Instance Method Summary collapse

Constructor Details

#initialize(cmd) ⇒ CommandTimeout


266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
# File 'lib/omnibus/exceptions.rb', line 266

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