Exception: JekyllSupport::CustomError
- Inherits:
-
StandardError
- Object
- Exception
- StandardError
- JekyllSupport::CustomError
- Defined in:
- lib/error/jekyll_custom_error.rb
Overview
Use like this: CustomError.new(:MyError, ‘blah’, ‘asdf’)
Class Method Summary collapse
Instance Method Summary collapse
- #calling_file ⇒ Object
- #error_name ⇒ Object
- #html_message ⇒ Object
- #logger_message ⇒ Object
- #shorten_backtrace(backtrace_element_count = 3) ⇒ Object
Class Method Details
.factory(error_class_name) ⇒ Object
8 9 10 11 12 |
# File 'lib/error/jekyll_custom_error.rb', line 8 def self.factory(error_class_name) return if Object.const_defined? "::#{error_class_name}" Object.const_set error_class_name, Class.new(CustomError) end |
Instance Method Details
#calling_file ⇒ Object
18 19 20 21 |
# File 'lib/error/jekyll_custom_error.rb', line 18 def calling_file file_fq, _line_number, _extra = backtrace[0]&.split(':') file_fq end |
#error_name ⇒ Object
14 15 16 |
# File 'lib/error/jekyll_custom_error.rb', line 14 def error_name self.class.name.split('::').last end |
#html_message ⇒ Object
24 25 26 27 28 29 30 31 32 33 |
# File 'lib/error/jekyll_custom_error.rb', line 24 def shorten_backtrace path, line_number, _caller = backtrace[1]&.split(':') <<~END_MSG <div class='#{error_name.snakecase}'> #{self.class} raised in #{calling_file} while processing line #{line_number} (after front matter) of #{path} #{} </div> END_MSG end |
#logger_message ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/error/jekyll_custom_error.rb', line 35 def shorten_backtrace kaller = caller(1..1).first path, line_number, _caller = backtrace[1]&.split(':') <<~END_MSG #{error_name} raised in #{kaller} while processing line #{line_number} (after front matter) of #{path} #{} END_MSG end |
#shorten_backtrace(backtrace_element_count = 3) ⇒ Object
45 46 47 48 49 50 |
# File 'lib/error/jekyll_custom_error.rb', line 45 def shorten_backtrace(backtrace_element_count = 3) b = backtrace[0..backtrace_element_count - 1].map do |x| x.gsub(Dir.pwd + '/', './') end set_backtrace b end |