Module: WebTools::Support::Debugger
Defined Under Namespace
Classes: Frame, ObjectLogError, Process, Wrapper
Constant Summary collapse
- ExceptionFrames =
[:raise, :"signal:", :"signal", "_rubyReraise"]
- RubyEnv =
1
Instance Method Summary collapse
-
#debug(reraise = false, &block) ⇒ Object
Calls the passed block in a new Thread.
-
#object_log ⇒ Object
Return the ObjectLog wrapper module.
-
#save_exception(exception) ⇒ Object
Saves an exception to the ObjectLog.
Instance Method Details
#debug(reraise = false, &block) ⇒ Object
Calls the passed block in a new Thread.
If the argument is true, any exception will be saved to the ObjectLog and re-raised. If the argument is false (default), any exception will wake the parent and suspend the failed thread for inspection.
> the suspended thread and the exception that stopped it, if any
> result of the passed block, if the thread finished
> raises Exception, if any
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/web_tools/support/debugger.rb', line 39 def debug(reraise = false, &block) raise ArgumentError, "must supply a block to debug" unless block client = Thread.start(Thread.current, block) do |parent_thread, blk| Thread.pass begin Thread.current[:result] = blk.call rescue Exception => e if reraise save_exception(e.) raise e else result = Process.new(Thread.current) result.exception = e Thread.current[:result] = result parent_thread.wakeup Thread.stop end end end client.join # raises exception if client aborted if (result = client[:result]).is_a? Process result.pop_exception_handling_frames end result end |
#object_log ⇒ Object
Return the ObjectLog wrapper module
13 14 15 |
# File 'lib/web_tools/support/debugger.rb', line 13 def object_log ObjectLog end |
#save_exception(exception) ⇒ Object
Saves an exception to the ObjectLog. This will abort the pending transaction.
20 21 22 23 24 25 26 27 |
# File 'lib/web_tools/support/debugger.rb', line 20 def save_exception(exception) if Maglev.needs_commit warn("Saving exception to ObjectLog, discarding transaction") end Maglev.abort_transaction DebuggerLogEntry.create_continuation_labeled(exception.) Maglev.commit_transaction end |