Exception: Pod::DSLError
- Inherits:
-
StandardError
- Object
- StandardError
- StandardError
- Pod::DSLError
- Defined in:
- lib/cocoapods-core/standard_error.rb
Overview
Wraps an exception raised by a DSL file in order to show to the user the contents of the line that raised the exception.
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
-
#initialize(description, dsl_path, backtrace) ⇒ DSLError
constructor
A new instance of DSLError.
-
#message ⇒ String
The message of the exception reports the content of podspec for the line that generated the original exception.
Constructor Details
#initialize(description, dsl_path, backtrace) ⇒ DSLError
30 31 32 33 34 |
# File 'lib/cocoapods-core/standard_error.rb', line 30 def initialize(description, dsl_path, backtrace) @description = description @dsl_path = dsl_path @backtrace = backtrace end |
Instance Attribute Details
#backtrace ⇒ Exception (readonly)
25 26 27 |
# File 'lib/cocoapods-core/standard_error.rb', line 25 def backtrace @backtrace end |
#description ⇒ String (readonly)
16 17 18 |
# File 'lib/cocoapods-core/standard_error.rb', line 16 def description @description end |
#dsl_path ⇒ String (readonly)
20 21 22 |
# File 'lib/cocoapods-core/standard_error.rb', line 20 def dsl_path @dsl_path end |
Instance Method Details
#message ⇒ String
The message of the exception reports the content of podspec for the line that generated the original exception.
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/cocoapods-core/standard_error.rb', line 54 def unless m = description.dup return m unless backtrace && dsl_path && File.exist?(dsl_path) trace_line = backtrace.find { |l| l =~ /#{dsl_path}/ } return m unless trace_line line_numer = trace_line.split(':')[1].to_i - 1 return m unless line_numer lines = File.readlines(dsl_path.to_s) indent = " # " indicator = indent.dup.gsub("#", ">") first_line = ( line_numer.zero? ) last_line = ( line_numer == (lines.count - 1) ) m << "\n #\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" m << " #" = m end end |