Sha256: 90dae2eaf45345d2884fe7c5d462d478dab6d627cf68e94e815c0a030952c33c
Contents?: true
Size: 1.31 KB
Versions: 3
Compression:
Stored size: 1.31 KB
Contents
module Heroku class Commander module Errors class CommandError < Heroku::Commander::Errors::Base attr_accessor :inner_exception def initialize(opts = {}) @inner_exception = opts[:inner_exception] opts = opts.dup prepare_lines(opts) prepare_status_message(opts) prepare_pid(opts) super(compose_message("command_error", opts)) end private def prepare_status_message(opts) if opts[:status] && opts[:status] != "" opts[:status_message] = " with exit status #{opts[:status]}" else opts[:status_message] = " without reporting an exit status" end end def prepare_lines(opts) if opts[:lines] && opts[:lines].size > 4 lines = opts[:lines][0..2] lines.push "... skipping #{opts[:lines].size - 4} line(s) ..." lines.concat opts[:lines][-2..-1] opts[:lines] = "\n\t" + lines.join("\n\t") elsif opts[:lines] opts[:lines] = "\n\t" + opts[:lines].join("\n\t") end end def prepare_pid(opts) if opts[:pid] opts[:pid] = " (pid: #{opts[:pid]})" end end end end end end
Version data entries
3 entries across 3 versions & 1 rubygems