pry-exception_explorer

(C) John Mair (banisterfiend) 2011

Enter the context of exceptions

pry-exception_explorer is an interactive error console for MRI Ruby 1.9.2+ inspired by the Hammertime
gem, which was in turn inspired by consoles found in the Lisp and Smalltalk environments. pry-exception_explorer is a plugin
for the Pry REPL.

Note, like the hammertime gem, pry-exception_explorer can only really intercept exceptions that are explicitly raised (using the raise method) from Ruby code.
This means that exceptions raised by syntax errors or from code such as 1/0 cannot be intercepted. Though experimental support for intercepting such deep (c-level) exceptions is provided by invoking with pry --c-exceptions.

Using pry-exception_explorer we can automatically pull up a Pry session at the point an exception arises and use Pry
to inspect the state there to debug (and fix) the problem. We also get access to the entire call stack of the exception and can walk the stack to interactively examine the state in
parent frames (using pry-stack_explorer).

Also look at the plymouth project which utilizes pry-exception_explorer to intercept test failures.

Example:

In the Ruby file:

require'pry-exception_explorer'EE.enabled=trueEE.intercept(ArgumentError)defalphaname="john"betaputsnameenddefbetax="john"gamma(x)enddefgamma(x)raiseArgumentError,"x must be a number!"if!x.is_a?(Numeric)puts"2 * x = #{2*x}"endalpha

Limitations

Contact

License

(The MIT License)

Copyright (c) 2011 John Mair (banisterfiend)

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.