Sha256: 51f16930e1bb332f26423fbdf943a15600666d86d123fadfe85b20739977eff7
Contents?: true
Size: 1.14 KB
Versions: 58
Compression:
Stored size: 1.14 KB
Contents
# MONKEY PATCH: Got tired of having no idea what line server side errors are # happening on, so I patched this bit of ExecJS so it would dump the whole # stack trace in the log. class ExecJS::RubyRacerRuntime::Context < ExecJS::Runtime::Context def eval(source, options = {}) source = encode(source) return unless /\S/ =~ source lock do begin unbox @v8_context.eval("(#{source})") rescue ::V8::JSError, ::V8::Error => e # Make V8 errors fatal on development, log them on staging/prod fail e if Rails.env.development? do_error(e) end end # /lock end def do_error(e) puts "========EXECJS ERROR========" puts js_lines(e.backtrace) puts "============================" if e.value["name"] == "SyntaxError" raise ExecJS::RuntimeError, e.value.to_s else raise ExecJS::ProgramError, e.value.to_s end end # Get just the JS related lines of the backtrace, not the 200 levels of rails # abstraction def js_lines(backtrace) first_ruby_line = backtrace.find_index { |line| line.include? 'execjs' } return backtrace[0...first_ruby_line] end end
Version data entries
58 entries across 58 versions & 1 rubygems