module WebTools::Support::Debugger
Constants
- ExceptionFrames
- RubyEnv
Public Instance Methods
debug(reraise = false, &block)
click to toggle source
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¶ ↑
# 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.message) 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()
click to toggle source
Return the ObjectLog
wrapper module
# File lib/web_tools/support/debugger.rb, line 13 def object_log ObjectLog end
save_exception(exception)
click to toggle source
Saves an exception to the ObjectLog
. This will abort the pending transaction.
# 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.message) Maglev.commit_transaction end