Class: RenderMePretty::Erb::MainErrorHandler
- Inherits:
-
BaseHandler
- Object
- BaseHandler
- RenderMePretty::Erb::MainErrorHandler
- Defined in:
- lib/render_me_pretty/erb/main_error_handler.rb
Instance Method Summary collapse
- #error_in_layout? ⇒ Boolean
-
#find_line_number ⇒ Object
For general Tilt errors first line of the backtrace that contains the path of the file we're rendeirng and has the line number.
Methods inherited from BaseHandler
#backtrace_lines, #handle, #initialize, #pretty_trace, #template_path_with_error
Constructor Details
This class inherits a constructor from RenderMePretty::Erb::BaseHandler
Instance Method Details
#error_in_layout? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/render_me_pretty/erb/main_error_handler.rb', line 22 def error_in_layout? # The first line of the backtrace has the template path that errored error_info = @exception.backtrace[0] error_info.include?(@layout_path) if @layout_path end |
#find_line_number ⇒ Object
For general Tilt errors first line of the backtrace that contains the path of the file we're rendeirng and has the line number. Example:
spec/fixtures/invalid.erb:2:in `block in singleton class'
error_info = e.backtrace[0]
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/render_me_pretty/erb/main_error_handler.rb', line 8 def find_line_number lines = @exception.backtrace error_line = lines.find do |line| line.include?(template_path_with_error) end if error_line.nil? puts "WARN: Unable to find line number. Fallback and print out full backtrace." puts @exception.backtrace else error_line.split(":")[1].to_i end end |