Skip to content
banister edited this page Feb 15, 2012 · 12 revisions

Pry Stack explorer

Quick Menu:

Overview

pry-exception_explorer is a plugin for the Pry REPL designed to intercept exceptions in your code. Once inside the session you have an opportunity to uncover the cause of the error and even to correct it, before letting your program continue. It is based on similar error consoles found in the Lisp and Smalltalk worlds.

Back to the top

EE shortcut

As an alternative to using the full module name PryExceptionExplorer, you can use the constant EE instead. They both refer to the same object, but the abbreviated form may make programs more concise.

Back to the top

The intercept method

This method allows the user to define the situations where an exception interception occurs. This method can be invoked in two ways.

1. Block-form

The general form takes a block, the block is passed both the frame where the exception was raised, and the exception itself. The user then creates an assertion (a stack-assertion) based on these attributes. If the assertion is later satisfied by a raised exception, that exception will be intercepted.

The first parameter yielded to the block is a PryExceptionExplorer::LazyFrame instance ( representing the context where the exception was raised), the second is the exception object.

The PryExceptionExplorer::LazyFrame instance supports a number of methods that expose details of the stack frame:

Clone this wiki locally