class Exception
Public Instance Methods
bindings()
click to toggle source
The bindings in which the exception originated in.
# File lib/web_console/core_ext/exception/cruby.rb, line 9 def bindings @bindings || __better_errors_bindings_stack end
initialize_with_binding_of_caller(*args)
click to toggle source
JRuby won't call Exception#set_backtrace when raising, so we can't hook in there. Our best bet is to hook into Exception#initialize, however we have the problem that a subclass may forget to call super in its override.
# File lib/web_console/core_ext/exception/jruby.rb, line 10 def initialize_with_binding_of_caller(*args) unless Thread.current[:__web_console_exception_lock] Thread.current[:__web_console_exception_lock] = true begin @bindings = binding.callers.drop(1) ensure Thread.current[:__web_console_exception_lock] = false end end initialize_without_binding_of_caller(*args) end
set_backtrace_with_binding_of_caller(*args)
click to toggle source
CRuby calls set_backtrace every time it raises an exception. Overriding it to assign the bindings.
# File lib/web_console/core_ext/exception/cruby.rb, line 20 def set_backtrace_with_binding_of_caller(*args) # Thanks to @charliesome who wrote this bit for better_errors. unless Thread.current[:__web_console_exception_lock] Thread.current[:__web_console_exception_lock] = true begin # Raising an exception here will cause all of the rubies to go into a # stack overflow. Some rubies may even segfault. See # https://bugs.ruby-lang.org/issues/10164 for details. @bindings = binding.callers.drop(1) ensure Thread.current[:__web_console_exception_lock] = false end end set_backtrace_without_binding_of_caller(*args) end