class Bundler::Dsl::DSLError
属性
backtrace[R]
@return [Exception] 由异常引发的回溯
evaluation of the dsl file.
description[R]
@return [String] 应该呈现给用户的描述。
dsl_path[R]
@return [String] 引发异常的 dsl 文件的路径。
公共类方法
new(description, dsl_path, backtrace, contents = nil) 点击以切换源代码
@param [Exception] backtrace @see backtrace @param [String] dsl_path
@see dsl_path
# File bundler/dsl.rb, line 547 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
公共实例方法
contents() 点击以切换源代码
@return [String] 导致异常的 DSL 内容
be raised.
# File bundler/dsl.rb, line 563 def contents @contents ||= dsl_path && File.exist?(dsl_path) && File.read(dsl_path) end
status_code() 点击以切换源代码
调用父类方法
# File bundler/dsl.rb, line 556 def status_code @status_code || super end
to_s() 点击以切换源代码
异常的消息报告生成原始异常的 podspec 的内容行。
@example 输出
Invalid podspec at `RestKit.podspec` - undefined method `exclude_header_search_paths=' for #<Pod::Specification for `RestKit/Network (0.9.3)`> from spec-repos/master/RestKit/0.9.3/RestKit.podspec:36 ------------------------------------------- # because it would break: #import <CoreData/CoreData.h> > ns.exclude_header_search_paths = 'Code/RestKit.h' end -------------------------------------------
@return [String] 异常的消息。
# File bundler/dsl.rb, line 585 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) } || trace_line return m unless trace_line line_number = trace_line.split(":")[1].to_i - 1 return m unless line_number lines = contents.lines.to_a indent = " # " indicator = indent.tr("#", ">") first_line = line_number.zero? last_line = (line_number == (lines.count - 1)) m << "\n" m << "#{indent}from #{trace_line.gsub(/:in.*$/, "")}\n" m << "#{indent}-------------------------------------------\n" m << "#{indent}#{lines[line_number - 1]}" unless first_line m << "#{indicator}#{lines[line_number]}" m << "#{indent}#{lines[line_number + 1]}" unless last_line m << "\n" unless m.end_with?("\n") m << "#{indent}-------------------------------------------\n" end end
私有实例方法
parse_line_number_from_description() 点击以切换源代码
# File bundler/dsl.rb, line 619 def parse_line_number_from_description description = self.description if dsl_path && description =~ /((#{Regexp.quote File.expand_path(dsl_path)}|#{Regexp.quote dsl_path}):\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