1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Add Uncaught Exceptions In Pry as a ruby til.

This commit is contained in:
jbranchaud
2015-08-30 14:52:14 -05:00
parent c00d4f5d11
commit 9777e8e0ac
2 changed files with 22 additions and 0 deletions

View File

@@ -131,6 +131,7 @@ smart people at [Hashrocket](http://hashrocket.com/).
- [Rake Only Lists Tasks With Descriptions](ruby/rake-only-lists-tasks-with-descriptions.md)
- [Squeeze Out The Extra Space](ruby/squeeze-out-the-extra-space.md)
- [Summing Collections](ruby/summing-collections.md)
- [Uncaught Exceptions In Pry](ruby/uncaught-exceptions-in-pry.md)
- [`undef_method` And The Inheritance Hierarchy](ruby/undef-method-and-the-inheritance-hierarchy.md)
### tmux

View File

@@ -0,0 +1,21 @@
# Uncaught Exceptions In Pry
You are fiddling around with some code in a pry session trying to
familiarize yourself with how it all works. You suddenly execute a statement
that results in an uncaught exception. You'd like to take a closer look at
the exception. Pry makes this easy by exposing the `_ex_` variable which
points to the last uncaught exception.
Try it out in a pry session:
```ruby
> class MyError < StandardError; end
=> nil
> def do_stuff; raise MyError, "Something bad happened"; end
=> :do_stuff
> do_stuff
MyError: Something bad happened
from (pry):2:in `do_stuff'
> _ex_
=> #<MyError: Something bad happened>
```