diff --git a/Gemfile.lock b/Gemfile.lock index c56ec3d19..2d2c55e40 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ GIT GIT remote: https://github.com/irrationalfab/PrettyBacon.git - revision: 0da7e231bf597005aaa4efb4c2cd837336a6b42b + revision: 926c214ade1ec1cbc9544d603e36f15a780f7e68 branch: master specs: prettybacon (0.0.1) diff --git a/lib/cocoapods-core/specification.rb b/lib/cocoapods-core/specification.rb index 0d533f3d1..f7af0cbc3 100644 --- a/lib/cocoapods-core/specification.rb +++ b/lib/cocoapods-core/specification.rb @@ -607,8 +607,7 @@ def self._eval_podspec(string, path) begin eval(string, nil, path.to_s) rescue Exception => e - raise DSLError.new("Invalid `#{path.basename}` file: #{e.message}", - path, e.backtrace) + raise DSLError.new("Invalid `#{path.basename}` file: #{e.message}", path, e.backtrace) end end end diff --git a/lib/cocoapods-core/standard_error.rb b/lib/cocoapods-core/standard_error.rb index ca6c2e14a..0f6570f22 100644 --- a/lib/cocoapods-core/standard_error.rb +++ b/lib/cocoapods-core/standard_error.rb @@ -9,7 +9,7 @@ class StandardError < ::StandardError; end # Wraps an exception raised by a DSL file in order to show to the user the # contents of the line that raised the exception. # - class DSLError < StandardError + class DSLError < Informative # @return [String] the description that should be presented to the user. # @@ -53,11 +53,14 @@ def initialize(description, dsl_path, backtrace) # def message unless @message - m = description.dup + m = "\n[!] " + m << description + m << ". Updating CocoaPods might fix the issue.\n" + m = m.red if m.respond_to?(:red) return m unless backtrace && dsl_path && File.exist?(dsl_path) - trace_line = backtrace.find { |l| l =~ /#{dsl_path}/ } + trace_line = backtrace.find { |l| l.include?(dsl_path.to_s) } return m unless trace_line line_numer = trace_line.split(':')[1].to_i - 1 return m unless line_numer @@ -67,7 +70,7 @@ def message first_line = ( line_numer.zero? ) last_line = ( line_numer == (lines.count - 1) ) - m << "\n #\n" + m << "\n" m << "#{indent}from #{trace_line.gsub(/:in.*$/,'')}\n" m << "#{indent}-------------------------------------------\n" m << "#{indent}#{ lines[line_numer - 1] }" unless first_line @@ -75,7 +78,7 @@ def message m << "#{indent}#{ lines[line_numer + 1] }" unless last_line m << "\n" unless m.end_with?("\n") m << "#{indent}-------------------------------------------\n" - m << " #" + m << "" @message = m end @message