Module: PryExceptionExplorer::CoreExtensions
- Included in:
- Object
- Defined in:
- lib/pry-exception_explorer/core_ext.rb
Instance Method Summary collapse
-
#raise(*args) ⇒ Object
We monkey-patch the
raise
method so we can intercept exceptions.
Instance Method Details
#raise(*args) ⇒ Object
We monkey-patch the raise
method so we can intercept exceptions
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/pry-exception_explorer/core_ext.rb', line 64 def raise(*args) exception, string, array = args if exception.is_a?(String) string = exception exception = RuntimeError end if exception.is_a?(Exception) || (exception.is_a?(Class) && exception < Exception) if PryExceptionExplorer.enabled? ex = string ? exception.exception(string) : exception.exception else return super(*args) end elsif exception.nil? if $! if PryExceptionExplorer.enabled? ex = $!.exception else return super($!) end else if PryExceptionExplorer.enabled? ex = RuntimeError.exception else return super(RuntimeError) end end else if PryExceptionExplorer.enabled? ex = RuntimeError.exception else return super(*args) end end ex.set_backtrace(array ? array : caller) intercept_object = PryExceptionExplorer.intercept_object if PryExceptionExplorer.should_intercept_exception?(binding.of_caller(1), ex) ex.exception_call_stack = binding.callers.tap { |v| v.shift(1 + intercept_object.skip_num) } PryExceptionExplorer.amend_exception_call_stack!(ex) ex.should_intercept = true if PryExceptionExplorer.inline? retval = PryExceptionExplorer.enter_exception(ex, :inline => true) end end if retval != PryExceptionExplorer::CONTINUE_INLINE_EXCEPTION callcc do |cc| ex.continuation = cc super(ex) end end end |