Class: Steep::Diagnostic::Ruby::UnexpectedError
- Defined in:
- lib/steep/diagnostic/ruby.rb
Instance Attribute Summary collapse
-
#error ⇒ Object
readonly
Returns the value of attribute error.
Attributes inherited from Base
Instance Method Summary collapse
- #detail_lines ⇒ Object
- #header_line ⇒ Object
-
#initialize(node:, error:) ⇒ UnexpectedError
constructor
A new instance of UnexpectedError.
Methods inherited from Base
Methods included from Helper
Constructor Details
#initialize(node:, error:) ⇒ UnexpectedError
Returns a new instance of UnexpectedError.
780 781 782 783 |
# File 'lib/steep/diagnostic/ruby.rb', line 780 def initialize(node:, error:) super(node: node) @error = error end |
Instance Attribute Details
#error ⇒ Object (readonly)
Returns the value of attribute error.
778 779 780 |
# File 'lib/steep/diagnostic/ruby.rb', line 778 def error @error end |
Instance Method Details
#detail_lines ⇒ Object
789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 |
# File 'lib/steep/diagnostic/ruby.rb', line 789 def detail_lines if trace = error.backtrace io = StringIO.new total = trace.size if total > 30 trace = trace.take(15) end trace.each.with_index do |line, index| io.puts "#{index+1}. #{line}" end if trace.size != total io.puts " (#{total - trace.size} more backtrace)" end io.string end end |
#header_line ⇒ Object
785 786 787 |
# File 'lib/steep/diagnostic/ruby.rb', line 785 def header_line "UnexpectedError: #{error.}(#{error.class})" end |