Module: RubyFriendlyError

Defined in:
lib/ruby_friendly_error.rb,
lib/ruby_friendly_error/version.rb

Constant Summary collapse

ROOT_PATH =
Pathname.new(__FILE__).dirname.parent.to_s
WINDOW =
2
VERSION =
'0.0.1'

Class Method Summary collapse

Class Method Details

.exec(file_content, file_name = '(eval)') ⇒ Object



30
31
32
33
34
35
36
# File 'lib/ruby_friendly_error.rb', line 30

def exec file_content, file_name = '(eval)'
  eval file_content, nil, file_name # rubocop:disable Security/Eval
rescue Exception => ex # rubocop:disable Lint/RescueException
  exception_file_name    = file_name == '(eval)' ? file_name : ex.backtrace.first.match(/(.+):[0-9]+:/)[1]
  exception_file_content = file_name == '(eval)' ? file_content : File.read(exception_file_name)
  exception_handling ex, exception_file_name, exception_file_content, file_name != '(eval)'
end

.load(file_path) ⇒ Object



26
27
28
# File 'lib/ruby_friendly_error.rb', line 26

def load file_path
  exec File.read(file_path), file_path
end