class Bundler::Dsl::DSLError



@return [Exception] the backtrace of the exception raised by the

evaluation of the dsl file.

@return [String] the description that should be presented to the user.


@return [String] the path of the dsl file that raised the exception.

Public Class Methods

new(description, dsl_path, backtrace, contents = nil) click to toggle source

@param [Exception] backtrace @see backtrace @param [String] dsl_path @see dsl_path

# File 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

Public Instance Methods

contents() click to toggle source

@return [String] the contents of the DSL that cause the exception to

be raised.
# File bundler/dsl.rb, line 512
def contents
  @contents ||= dsl_path && File.exist?(dsl_path) &&
status_code() click to toggle source
Calls superclass method
# File bundler/dsl.rb, line 505
def status_code
  @status_code || super
to_s() click to toggle source

The message of the exception reports the content of podspec for the line that generated the original exception.

@example Output

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'

@return [String] the message of the exception.

# File bundler/dsl.rb, line 534
def to_s
  @to_s ||= begin
    trace_line, description = parse_line_number_from_description

    m ="\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  ="#", ">")
    first_line =
    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"