lib/travis/cli/command.rb in travis-1.9.2.travis.1224.9 vs lib/travis/cli/command.rb in travis-1.9.2.travis.1236.9

- old
+ new

@@ -159,13 +159,13 @@ last_check['at'] = Time.now.to_i unless Tools::System.recent_version? Travis::VERSION, last_check['version'] warn "Outdated CLI version, run `gem install travis`." end - rescue Timeout::Error, Faraday::Error::ClientError => error + rescue Timeout::Error, Faraday::ClientError => error debug "#{error.class}: #{error.message}" - rescue JSON::ParseError => error + rescue JSON::ParserError => error warn "Unable to determine the most recent travis gem version. http://rubygems.org may be down." end def check_completion return if skip_completion_check? or !interactive? @@ -277,10 +277,22 @@ def on_signal(&block) @on_signal << block end + def warn(message) + write_to($stderr) do + say color(message, :error) + yield if block_given? + end + end + + def error(message, &block) + warn(message, &block) + exit 1 + end + private def store_error(exception) message = "An error occurred running `travis %s%s`:\n %p: %s\n" % [command_name, endpoint_option, exception.class, exception.message] exception.backtrace.each { |l| message << " from #{l}\n" } @@ -322,21 +334,9 @@ force_interactive end def empty_line say "\n" - end - - def warn(message) - write_to($stderr) do - say color(message, :error) - yield if block_given? - end - end - - def error(message, &block) - warn(message, &block) - exit 1 end def command(name) color("#{File.basename($0)} #{name}", :command) end