Exception: Bundler::Dsl::DSLError
Relationships & Source Files | |
Super Chains via Extension / Inclusion / Inheritance | |
Class Chain:
self,
::Bundler::GemfileError ,
::Bundler::BundlerError ,
StandardError
|
|
Instance Chain:
self,
::Bundler::GemfileError ,
::Bundler::BundlerError ,
StandardError
|
|
Inherits: |
Bundler::GemfileError
|
Defined in: | lib/bundler/dsl.rb |
Class Method Summary
::Bundler::BundlerError
- Inherited
Instance Attribute Summary
- #backtrace ⇒ Exception readonly
- #description ⇒ String readonly
- #dsl_path ⇒ String readonly
Instance Method Summary
- #contents ⇒ String
- #status_code
-
#to_s ⇒ String
The message of the exception reports the content of podspec for the line that generated the original exception.
- #parse_line_number_from_description private
Constructor Details
.new(description, dsl_path, backtrace, contents = nil) ⇒ DSLError
# File 'lib/bundler/dsl.rb', line 496
def initialize(description, dsl_path, backtrace, contents = nil) @status_code = $!.respond_to?(:status_code) && $!.status_code @description = description @dsl_path = dsl_path @backtrace = backtrace @contents = contents end
Instance Attribute Details
#backtrace ⇒ Exception
(readonly)
# File 'lib/bundler/dsl.rb', line 491
attr_reader :backtrace
#description ⇒ String
(readonly)
# File 'lib/bundler/dsl.rb', line 482
attr_reader :description
#dsl_path ⇒ String
(readonly)
# File 'lib/bundler/dsl.rb', line 486
attr_reader :dsl_path
Instance Method Details
#contents ⇒ String
#parse_line_number_from_description (private)
[ GitHub ]# File 'lib/bundler/dsl.rb', line 568
def parse_line_number_from_description description = self.description if dsl_path && description =~ /((#{Regexp.quote File. (dsl_path)}|#{Regexp.quote dsl_path.to_s}):\d+)/ trace_line = Regexp.last_match[1] description = description.sub(/\n.*\n(\.\.\.)? *\^~+$/, "").sub(/#{Regexp.quote trace_line}:\s*/, "").sub("\n", " - ") end [trace_line, description] end
#status_code
[ GitHub ]# File 'lib/bundler/dsl.rb', line 505
def status_code @status_code || super end
#to_s ⇒ String
The message of the exception reports the content of podspec for the line that generated the original exception.
# File 'lib/bundler/dsl.rb', line 534
def to_s @to_s ||= begin trace_line, description = parse_line_number_from_description m = String.new("\n[!] ") m << description m << ". Bundler cannot continue.\n" return m unless backtrace && dsl_path && contents trace_line = backtrace.find {|l| l.include?(dsl_path.to_s) } || trace_line return m unless trace_line line_numer = trace_line.split(":")[1].to_i - 1 return m unless line_numer lines = contents.lines.to_a indent = " # " indicator = indent.tr("#", ">") first_line = line_numer.zero? last_line = (line_numer == (lines.count - 1)) m << "\n" m << "#{indent}from #{trace_line.gsub(/:in.*$/, "")}\n" m << "#{indent}-------------------------------------------\n" m << "#{indent}#{lines[line_numer - 1]}" unless first_line m << "#{indicator}#{lines[line_numer]}" m << "#{indent}#{lines[line_numer + 1]}" unless last_line m << "\n" unless m.end_with?("\n") m << "#{indent}-------------------------------------------\n" end end