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

Pry Stack explorer

Quick Menu:

Overview

...FIXME...

Back to the top

The show-stack command

The show-stack command is used to display the current backtrace. Unlike the normal Ruby caller method, it only displays those frames that are accessible to Pry -- so frames for C functions are skipped. The show-stack command can also display more information about each frame, including the frame type, and the class-name.

The following options are supported:

  • Use the -v option to include extra information such as the file and line associated with the frame.
  • Use the -H option to display the first N stack frames (defaults to 10).
  • Use the -T option to display the last N stack frames (defaults to 10).
  • Use the -c option to display N frames either side of current frame (default to 5).

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