pry-exception_explorer 0.1.1pre8 → 0.1.3pre1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +90 -7
- data/Rakefile +1 -1
- data/examples/example_inline.rb +6 -6
- data/lib/pry-exception_explorer/core_ext.rb +20 -10
- data/lib/pry-exception_explorer/version.rb +1 -1
- data/pry-exception_explorer.gemspec +3 -3
- metadata +40 -47
data/README.md
CHANGED
@@ -3,25 +3,108 @@ pry-exception_explorer
|
|
3
3
|
|
4
4
|
(C) John Mair (banisterfiend) 2011
|
5
5
|
|
6
|
-
|
6
|
+
_Enter the context of exceptions_
|
7
7
|
|
8
|
-
|
8
|
+
**Please note, this is a first release for pry-exception_explorer and as such it may still have teething
|
9
|
+
problems. If you encounter any quirks or crashes please [file an issue](https://github.com/pry/pry-exception_explorer/issues)**
|
10
|
+
|
11
|
+
`pry-exception_explorer` is an interactive error console for Ruby 1.9.2+ inspired by the [Hammertime](https://github.com/avdi/hammertime)
|
12
|
+
gem, which was in turn inspired by consoles found in the Lisp and Smalltalk environments. `pry-exception_explorer` is a plugin
|
13
|
+
for the [Pry REPL](http://pry.github.com).
|
14
|
+
|
15
|
+
Using `pry-exception_explorer` we can automatically pull up a [Pry](http://pry.github.com) session at the point an exception arises and use `Pry`
|
16
|
+
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
|
17
|
+
parent frames (using [pry-stack_explorer](https://github.com/pry/pry-stack_explorer)).
|
18
|
+
|
19
|
+
**Watch the mini-screencast:** http://vimeo.com/35953694
|
9
20
|
|
10
21
|
* Install the [gem](https://rubygems.org/gems/pry-exception_explorer): `gem install pry-exception_explorer`
|
11
22
|
* Read the [documentation](http://rdoc.info/github/banister/pry-exception_explorer/master/file/README.md)
|
12
23
|
* See the [source code](http://github.com/banister/pry-exception_explorer)
|
13
|
-
|
14
|
-
Example:
|
24
|
+
|
25
|
+
Example:
|
15
26
|
--------
|
16
27
|
|
17
|
-
|
28
|
+
In the Ruby file:
|
29
|
+
|
30
|
+
```ruby
|
31
|
+
require 'pry-exception_explorer'
|
32
|
+
|
33
|
+
PryExceptionExplorer.enabled = true
|
34
|
+
PryExceptionExplorer.intercept(ArgumentError)
|
35
|
+
|
36
|
+
def alpha
|
37
|
+
name = "john"
|
38
|
+
beta
|
39
|
+
puts name
|
40
|
+
end
|
41
|
+
|
42
|
+
def beta
|
43
|
+
x = "john"
|
44
|
+
gamma(x)
|
45
|
+
end
|
46
|
+
|
47
|
+
def gamma(x)
|
48
|
+
raise ArgumentError, "x must be a number!" if !x.is_a?(Numeric)
|
49
|
+
puts "2 * x = #{2 * x}"
|
50
|
+
end
|
51
|
+
|
52
|
+
alpha
|
53
|
+
|
54
|
+
```
|
18
55
|
|
19
|
-
|
56
|
+
The following session starts up:
|
57
|
+
|
58
|
+
```ruby
|
59
|
+
Frame number: 0/4
|
60
|
+
Frame type: method
|
61
|
+
|
62
|
+
From: /Users/john/ruby/projects/pry-exception_explorer/examples/example_inline.rb @ line 23 in Object#gamma:
|
63
|
+
|
64
|
+
18: x = "john"
|
65
|
+
19: gamma(x)
|
66
|
+
20: end
|
67
|
+
21:
|
68
|
+
22: def gamma(x)
|
69
|
+
=> 23: raise ArgumentError, "x must be a number!" if !x.is_a?(Numeric)
|
70
|
+
24: puts "2 * x = #{2 * x}"
|
71
|
+
25: end
|
72
|
+
26:
|
73
|
+
27: alpha
|
74
|
+
|
75
|
+
[1] (pry) main: 0> x
|
76
|
+
=> "john"
|
77
|
+
[2] (pry) main: 0> x = 7
|
78
|
+
=> 7
|
79
|
+
[3] (pry) main: 0> continue-exception
|
80
|
+
```
|
81
|
+
|
82
|
+
Since we fixed the problem (invalid type for `x` local) we can `continue-exception`, and have the method continue with the
|
83
|
+
amended `x`:
|
84
|
+
|
85
|
+
**PROGRAM OUTPUT:**
|
86
|
+
|
87
|
+
>> 2 * x = 14
|
88
|
+
|
89
|
+
>> john
|
20
90
|
|
21
91
|
Features and limitations
|
22
92
|
-------------------------
|
23
93
|
|
24
|
-
|
94
|
+
### Features
|
95
|
+
|
96
|
+
* Puts you in context of exception.
|
97
|
+
* Makes entire call stack accessible (useful for drilling down to precise cause of error).
|
98
|
+
* Allows you to 'continue' from exception, recovering from error (`continue-exception` command)
|
99
|
+
* Has limited/experimental ability to intercept exceptions that arise from C code (use `pry --c-exceptions` to enable).
|
100
|
+
* Let's you assert over state of entire stack when determining whether an exception should be intercepted.
|
101
|
+
* Let's you start the session on any stack frame.
|
102
|
+
|
103
|
+
### Limitations
|
104
|
+
|
105
|
+
* Only works on Ruby 1.9.2+ (including 1.9.3) MRI.
|
106
|
+
* Limited support for `C` exceptions -- only some exceptions that arise from C code are caught.
|
107
|
+
* Wiki documentation coming soon ;)
|
25
108
|
|
26
109
|
Contact
|
27
110
|
-------
|
data/Rakefile
CHANGED
data/examples/example_inline.rb
CHANGED
@@ -6,7 +6,7 @@ end
|
|
6
6
|
require 'pry-exception_explorer'
|
7
7
|
|
8
8
|
PryExceptionExplorer.enabled = true
|
9
|
-
PryExceptionExplorer.intercept(
|
9
|
+
PryExceptionExplorer.intercept(ArgumentError)
|
10
10
|
|
11
11
|
def alpha
|
12
12
|
name = "john"
|
@@ -15,13 +15,13 @@ def alpha
|
|
15
15
|
end
|
16
16
|
|
17
17
|
def beta
|
18
|
-
x =
|
19
|
-
gamma
|
20
|
-
puts x
|
18
|
+
x = "john"
|
19
|
+
gamma(x)
|
21
20
|
end
|
22
21
|
|
23
|
-
def gamma
|
24
|
-
raise "
|
22
|
+
def gamma(x)
|
23
|
+
raise ArgumentError, "x must be a number!" if !x.is_a?(Numeric)
|
24
|
+
puts "2 * x = #{2 * x}"
|
25
25
|
end
|
26
26
|
|
27
27
|
alpha
|
@@ -19,28 +19,38 @@ end
|
|
19
19
|
# `PryExceptionExplorer` monkey-patches to `Object`
|
20
20
|
class Object
|
21
21
|
|
22
|
-
#
|
23
|
-
def raise(
|
24
|
-
|
22
|
+
# We monkey-patch the `raise` method so we can intercept exceptions
|
23
|
+
def raise(*args)
|
24
|
+
exception, string, array = args
|
25
25
|
if exception.is_a?(String)
|
26
26
|
string = exception
|
27
27
|
exception = RuntimeError
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
30
|
+
if exception.is_a?(Exception)
|
31
|
+
return super(*args)
|
32
|
+
elsif exception.nil?
|
33
|
+
if $!
|
34
|
+
return super($!)
|
35
|
+
else
|
36
|
+
return super(RuntimeError)
|
37
|
+
end
|
38
|
+
else
|
39
|
+
ex = exception.exception(string)
|
40
|
+
ex.set_backtrace(array ? array : caller)
|
41
|
+
end
|
32
42
|
|
33
43
|
# revert to normal exception behaviour if EE not enabled.
|
34
|
-
if !PryExceptionExplorer.enabled?
|
35
|
-
return super(
|
44
|
+
if !PryExceptionExplorer.enabled?
|
45
|
+
return super(*args)
|
36
46
|
end
|
37
47
|
|
38
48
|
intercept_object = PryExceptionExplorer.intercept_object
|
39
|
-
|
49
|
+
|
40
50
|
if PryExceptionExplorer.should_intercept_exception?(binding.of_caller(1), ex)
|
41
|
-
ex.exception_call_stack = binding.callers.tap { |v| v.shift(1 + intercept_object.skip_num) }
|
51
|
+
ex.exception_call_stack = binding.callers.tap { |v| v.shift(1 + intercept_object.skip_num) }
|
42
52
|
PryExceptionExplorer.amend_exception_call_stack!(ex)
|
43
|
-
|
53
|
+
|
44
54
|
ex.should_intercept = true
|
45
55
|
|
46
56
|
if !PryExceptionExplorer.wrap_active?
|
@@ -2,11 +2,11 @@
|
|
2
2
|
|
3
3
|
Gem::Specification.new do |s|
|
4
4
|
s.name = "pry-exception_explorer"
|
5
|
-
s.version = "0.1.
|
5
|
+
s.version = "0.1.2"
|
6
6
|
|
7
|
-
s.required_rubygems_version = Gem::Requirement.new("
|
7
|
+
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
8
8
|
s.authors = ["John Mair (banisterfiend)"]
|
9
|
-
s.date = "2012-01
|
9
|
+
s.date = "2012-02-01"
|
10
10
|
s.description = "Enter the context of exceptions"
|
11
11
|
s.email = "jrmair@gmail.com"
|
12
12
|
s.files = [".gemtest", ".gitignore", ".travis.yml", ".yardopts", "CHANGELOG", "Gemfile", "LICENSE", "README.md", "Rakefile", "examples/example_c_inline.rb", "examples/example_inline.rb", "examples/example_wrap.rb", "lib/pry-exception_explorer.rb", "lib/pry-exception_explorer/cli.rb", "lib/pry-exception_explorer/commands.rb", "lib/pry-exception_explorer/core_ext.rb", "lib/pry-exception_explorer/intercept.rb", "lib/pry-exception_explorer/lazy_frame.rb", "lib/pry-exception_explorer/shim_builder.rb", "lib/pry-exception_explorer/version.rb", "pry-exception_explorer.gemspec", "test/helper.rb", "test/test_exceptions_in_pry.rb", "test/test_inline_exceptions.rb", "test/test_wrapped_exceptions.rb"]
|
metadata
CHANGED
@@ -1,59 +1,55 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: pry-exception_explorer
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.3pre1
|
4
5
|
prerelease: 5
|
5
|
-
version: 0.1.1pre8
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- John Mair (banisterfiend)
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-02-01 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: pry-stack_explorer
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: &70366152724100 !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
24
22
|
type: :runtime
|
25
|
-
version_requirements: *id001
|
26
|
-
- !ruby/object:Gem::Dependency
|
27
|
-
name: bacon
|
28
23
|
prerelease: false
|
29
|
-
|
24
|
+
version_requirements: *70366152724100
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: bacon
|
27
|
+
requirement: &70366152723200 !ruby/object:Gem::Requirement
|
30
28
|
none: false
|
31
|
-
requirements:
|
29
|
+
requirements:
|
32
30
|
- - ~>
|
33
|
-
- !ruby/object:Gem::Version
|
31
|
+
- !ruby/object:Gem::Version
|
34
32
|
version: 1.1.0
|
35
33
|
type: :development
|
36
|
-
version_requirements: *id002
|
37
|
-
- !ruby/object:Gem::Dependency
|
38
|
-
name: rake
|
39
34
|
prerelease: false
|
40
|
-
|
35
|
+
version_requirements: *70366152723200
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: rake
|
38
|
+
requirement: &70366152722480 !ruby/object:Gem::Requirement
|
41
39
|
none: false
|
42
|
-
requirements:
|
40
|
+
requirements:
|
43
41
|
- - ~>
|
44
|
-
- !ruby/object:Gem::Version
|
45
|
-
version:
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0.9'
|
46
44
|
type: :development
|
47
|
-
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70366152722480
|
48
47
|
description: Enter the context of exceptions
|
49
48
|
email: jrmair@gmail.com
|
50
49
|
executables: []
|
51
|
-
|
52
50
|
extensions: []
|
53
|
-
|
54
51
|
extra_rdoc_files: []
|
55
|
-
|
56
|
-
files:
|
52
|
+
files:
|
57
53
|
- .gemtest
|
58
54
|
- .gitignore
|
59
55
|
- .travis.yml
|
@@ -81,32 +77,29 @@ files:
|
|
81
77
|
- test/test_wrapped_exceptions.rb
|
82
78
|
homepage: https://github.com/banister/pry-exception_explorer
|
83
79
|
licenses: []
|
84
|
-
|
85
80
|
post_install_message:
|
86
81
|
rdoc_options: []
|
87
|
-
|
88
|
-
require_paths:
|
82
|
+
require_paths:
|
89
83
|
- lib
|
90
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
84
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
91
85
|
none: false
|
92
|
-
requirements:
|
93
|
-
- -
|
94
|
-
- !ruby/object:Gem::Version
|
95
|
-
version:
|
96
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ! '>='
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
97
91
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
92
|
+
requirements:
|
93
|
+
- - ! '>'
|
94
|
+
- !ruby/object:Gem::Version
|
101
95
|
version: 1.3.1
|
102
96
|
requirements: []
|
103
|
-
|
104
97
|
rubyforge_project:
|
105
|
-
rubygems_version: 1.8.
|
98
|
+
rubygems_version: 1.8.6
|
106
99
|
signing_key:
|
107
100
|
specification_version: 3
|
108
101
|
summary: Enter the context of exceptions
|
109
|
-
test_files:
|
102
|
+
test_files:
|
110
103
|
- test/helper.rb
|
111
104
|
- test/test_exceptions_in_pry.rb
|
112
105
|
- test/test_inline_exceptions.rb
|