Exception: Bundler::Dsl::DSLError
- Inherits:
-
GemfileError
- Object
- StandardError
- BundlerError
- GemfileError
- Bundler::Dsl::DSLError
- Defined in:
- lib/bundler/dsl.rb
Instance Attribute Summary collapse
-
#backtrace ⇒ Exception
readonly
The backtrace of the exception raised by the evaluation of the dsl file.
-
#description ⇒ String
readonly
The description that should be presented to the user.
-
#dsl_path ⇒ String
readonly
The path of the dsl file that raised the exception.
Instance Method Summary collapse
-
#contents ⇒ String
The contents of the DSL that cause the exception to be raised.
-
#initialize(description, dsl_path, backtrace, contents = nil) ⇒ DSLError
constructor
A new instance of DSLError.
- #status_code ⇒ Object
-
#to_s ⇒ String
The message of the exception reports the content of podspec for the line that generated the original exception.
Methods inherited from BundlerError
Constructor Details
#initialize(description, dsl_path, backtrace, contents = nil) ⇒ DSLError
Returns a new instance of DSLError.
411 412 413 414 415 416 417 418 |
# File 'lib/bundler/dsl.rb', line 411 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)
Returns the backtrace of the exception raised by the evaluation of the dsl file.
406 407 408 |
# File 'lib/bundler/dsl.rb', line 406 def backtrace @backtrace end |
#description ⇒ String (readonly)
Returns the description that should be presented to the user.
397 398 399 |
# File 'lib/bundler/dsl.rb', line 397 def description @description end |
#dsl_path ⇒ String (readonly)
Returns the path of the dsl file that raised the exception.
401 402 403 |
# File 'lib/bundler/dsl.rb', line 401 def dsl_path @dsl_path end |
Instance Method Details
#contents ⇒ String
Returns the contents of the DSL that cause the exception to be raised.
427 428 429 430 431 |
# File 'lib/bundler/dsl.rb', line 427 def contents @contents ||= begin dsl_path && File.exist?(dsl_path) && File.read(dsl_path) end end |
#status_code ⇒ Object
420 421 422 |
# File 'lib/bundler/dsl.rb', line 420 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.
451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 |
# File 'lib/bundler/dsl.rb', line 451 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 |