Skip to content

Commit

Permalink
Keep same error interface
Browse files Browse the repository at this point in the history
Only suppress backtrace from likely errors
  • Loading branch information
schneems committed Nov 3, 2014
1 parent b84422c commit 74cba7c
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 11 deletions.
2 changes: 1 addition & 1 deletion bin/compile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ rescue Exception => e
Kernel.puts " ! #{line.strip}"
end
Kernel.puts " !"
if e.is_a?(LanguagePack::BuildpackError)
if e.is_a?(BuildpackError)
exit 1
else
raise e
Expand Down
2 changes: 1 addition & 1 deletion lib/language_pack/helpers/bundler_wrapper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
class LanguagePack::Helpers::BundlerWrapper
include LanguagePack::ShellHelpers

class GemfileParseError < LanguagePack::BuildpackError
class GemfileParseError < BuildpackError
def initialize(error)
msg = "There was an error parsing your Gemfile, we cannot continue\n"
msg << error
Expand Down
4 changes: 2 additions & 2 deletions lib/language_pack/helpers/rake_runner.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def status?

# Is set by RakeTask#invoke to one of the ALLOWED verbs
def status
raise LanguagePack::BuildpackError, "Status not set for #{self.inspect}" if @status == :nil
raise LanguagePack::BuildpackError, "Not allowed status: #{@status} for #{self.inspect}" unless ALLOWED.include?(@status)
raise "Status not set for #{self.inspect}" if @status == :nil
raise "Not allowed status: #{@status} for #{self.inspect}" unless ALLOWED.include?(@status)
@status
end

Expand Down
2 changes: 1 addition & 1 deletion lib/language_pack/no_lockfile.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@ def name
end

def compile
raise LanguagePack::BuildpackError, "Gemfile.lock required. Please check it in."
error "Gemfile.lock required. Please check it in."
end
end
11 changes: 6 additions & 5 deletions lib/language_pack/ruby.rb
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ def slug_vendor_base
@slug_vendor_base = "vendor/bundle/1.8"
else
@slug_vendor_base = run_no_pipe(%q(ruby -e "require 'rbconfig';puts \"vendor/bundle/#{RUBY_ENGINE}/#{RbConfig::CONFIG['ruby_version']}\"")).chomp
raise LanguagePack::BuildpackError, "Problem detecting bundler vendor directory: #{@slug_vendor_base}" unless $?.success?
error "Problem detecting bundler vendor directory: #{@slug_vendor_base}" unless $?.success?
@slug_vendor_base
end
end
Expand Down Expand Up @@ -264,7 +264,7 @@ def install_ruby
expected_checksum = File.read(sha_file).chomp
actual_checksum = Digest::SHA1.file(file).hexdigest

raise LanguagePack::BuildpackError, <<-ERROR_MSG unless expected_checksum == actual_checksum
error <<-ERROR_MSG unless expected_checksum == actual_checksum
RBX Checksum for #{file} does not match.
Expected #{expected_checksum} but got #{actual_checksum}.
Please try pushing again in a few minutes.
Expand Down Expand Up @@ -309,8 +309,9 @@ def install_ruby
An error occurred while installing Ruby #{ruby_version.version}
For supported Ruby versions see https://devcenter.heroku.com/articles/ruby-support#supported-runtimes
Note: Only the most recent version of Ruby 2.1 is supported on Cedar-14
#{error.message}
ERROR
raise LanguagePack::BuildpackError, message + error.message
error message
end

def new_app?
Expand Down Expand Up @@ -550,7 +551,7 @@ def build_bundler
ERROR
end

raise LanguagePack::BuildpackError, error_message
error error_message
end
end
end
Expand Down Expand Up @@ -719,7 +720,7 @@ def precompile_fail(output)
msg << "Attempted to access a nonexistent database:\n"
msg << "https://devcenter.heroku.com/articles/pre-provision-database\n"
end
raise LanguagePack::BuildpackError, msg
error msg
end

def bundler_cache
Expand Down
2 changes: 1 addition & 1 deletion lib/language_pack/ruby_version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

module LanguagePack
class RubyVersion
class BadVersionError < LanguagePack::BuildpackError
class BadVersionError < BuildpackError
def initialize(output = "")
msg = ""
msg << output
Expand Down
8 changes: 8 additions & 0 deletions lib/language_pack/shell_helpers.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
require "shellwords"


class BuildpackError < StandardError
end

class NoShellEscape < String
def shellescape
self
Expand Down Expand Up @@ -122,6 +126,10 @@ def warn(message, options = {})
@warnings << message
end

def error(message)
raise BuildpackError, message
end

def deprecate(message)
@deprecations ||= []
@deprecations << message
Expand Down

0 comments on commit 74cba7c

Please sign in to comment.