diff options
author | Eli Rose <really.eli@gmail.com> | 2019-02-17 23:07:16 -0500 |
---|---|---|
committer | Eli Rose <really.eli@gmail.com> | 2019-02-17 23:07:16 -0500 |
commit | 07804d4759726da04020834502d37a8f4ac97a8f (patch) | |
tree | 711b1912e1527c6d0e80b85ad19bf555ce539ffe /actionview/lib/action_view/template/error.rb | |
parent | ac68550ae6d117b1d257f5df38ba76e03b7e2cf4 (diff) | |
download | rails-07804d4759726da04020834502d37a8f4ac97a8f.tar.gz rails-07804d4759726da04020834502d37a8f4ac97a8f.tar.bz2 rails-07804d4759726da04020834502d37a8f4ac97a8f.zip |
Add handling and tests.
Diffstat (limited to 'actionview/lib/action_view/template/error.rb')
-rw-r--r-- | actionview/lib/action_view/template/error.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/actionview/lib/action_view/template/error.rb b/actionview/lib/action_view/template/error.rb index 4e3c02e05e..ff01e4cd83 100644 --- a/actionview/lib/action_view/template/error.rb +++ b/actionview/lib/action_view/template/error.rb @@ -138,4 +138,24 @@ module ActionView end TemplateError = Template::Error + + class SyntaxErrorInTemplate < TemplateError #:nodoc + def initialize(template, offending_code_string) + @offending_code_string = offending_code_string + super(template) + end + + def message + <<~MESSAGE + Encountered a syntax error while rendering template: check #{@offending_code_string} + MESSAGE + end + + def annoted_source_code + @offending_code_string.split("\n").map.with_index(1) { |line, index| + indentation = " " * 4 + "#{index}:#{indentation}#{line}" + } + end + end end |