better_errors 2.0.0 → 2.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.coveralls.yml +1 -0
- data/.gitignore +3 -0
- data/.travis.yml +96 -2
- data/CHANGELOG.md +1 -1
- data/Gemfile +2 -7
- data/LICENSE.txt +1 -1
- data/README.md +99 -39
- data/better_errors.gemspec +23 -4
- data/gemfiles/pry010.gemfile +9 -0
- data/gemfiles/pry011.gemfile +8 -0
- data/gemfiles/pry09.gemfile +8 -0
- data/gemfiles/rack.gemfile +7 -0
- data/gemfiles/rack_boc.gemfile +8 -0
- data/gemfiles/rails42.gemfile +9 -0
- data/gemfiles/rails42_boc.gemfile +10 -0
- data/gemfiles/rails42_haml.gemfile +10 -0
- data/gemfiles/rails50.gemfile +8 -0
- data/gemfiles/rails50_boc.gemfile +9 -0
- data/gemfiles/rails50_haml.gemfile +9 -0
- data/gemfiles/rails51.gemfile +8 -0
- data/gemfiles/rails51_boc.gemfile +9 -0
- data/gemfiles/rails51_haml.gemfile +9 -0
- data/gemfiles/rails52.gemfile +8 -0
- data/gemfiles/rails52_boc.gemfile +9 -0
- data/gemfiles/rails52_haml.gemfile +9 -0
- data/gemfiles/rails60.gemfile +7 -0
- data/gemfiles/rails60_boc.gemfile +8 -0
- data/gemfiles/rails60_haml.gemfile +8 -0
- data/lib/better_errors/code_formatter/html.rb +1 -1
- data/lib/better_errors/code_formatter.rb +7 -7
- data/lib/better_errors/error_page.rb +56 -15
- data/lib/better_errors/inspectable_value.rb +45 -0
- data/lib/better_errors/middleware.rb +96 -16
- data/lib/better_errors/raised_exception.rb +13 -3
- data/lib/better_errors/repl/basic.rb +3 -3
- data/lib/better_errors/repl/pry.rb +18 -8
- data/lib/better_errors/repl.rb +6 -4
- data/lib/better_errors/stack_frame.rb +33 -8
- data/lib/better_errors/templates/main.erb +71 -34
- data/lib/better_errors/templates/text.erb +2 -2
- data/lib/better_errors/templates/variable_info.erb +32 -23
- data/lib/better_errors/version.rb +1 -1
- data/lib/better_errors.rb +21 -3
- metadata +118 -35
- data/Rakefile +0 -13
- data/spec/better_errors/code_formatter_spec.rb +0 -92
- data/spec/better_errors/error_page_spec.rb +0 -76
- data/spec/better_errors/middleware_spec.rb +0 -154
- data/spec/better_errors/raised_exception_spec.rb +0 -52
- data/spec/better_errors/repl/basic_spec.rb +0 -18
- data/spec/better_errors/repl/pry_spec.rb +0 -40
- data/spec/better_errors/repl/shared_examples.rb +0 -18
- data/spec/better_errors/stack_frame_spec.rb +0 -157
- data/spec/better_errors/support/my_source.rb +0 -20
- data/spec/better_errors_spec.rb +0 -73
- data/spec/spec_helper.rb +0 -5
- data/spec/without_binding_of_caller.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 10f7411145be495cf17cbebdf087e1bb21fe8c6fc8c07397fa406e7fc1f9f917
|
4
|
+
data.tar.gz: 3b14b75eaa97285c3ad5f685671348694aa7174cc43e52826e49e21a2f139b0d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 141e1056c402ed7b0aa0965278018096ca1d2bc4032072692c1f146ad09d6848d87792d665ecc6dcb41322594e91d9a5e27955edc560bb665a2995f150c0be4e
|
7
|
+
data.tar.gz: 03a94aa9fdcd0340b1fdf913a52978437692587efabe196ebb119087712086cc304289ec1c684ab4efbdece115a4bd1298b57bf58699a0d672f76f6aa196793b
|
data/.coveralls.yml
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
service_name: travis-ci
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,4 +1,98 @@
|
|
1
1
|
language: ruby
|
2
|
+
cache: bundler
|
3
|
+
notifications:
|
4
|
+
webhooks:
|
5
|
+
# With COVERALLS_PARALLEL, coverage information sent to coveralls will not be processed until
|
6
|
+
# this webhook is sent.
|
7
|
+
# https://coveralls.zendesk.com/hc/en-us/articles/203484329-Parallel-Build-Webhook
|
8
|
+
- secure: "YnHYbTq51ySistjvOxsuNhyg4GLuUffEJstTYeGYXiBF7HG5h43IVYo8KNuLzwkgsOYBcNo+YMdQX7qCqJffSbhsr1FZRSzBmjFFxcyD4hu+ukM2theZ4mePVAZiePscYvQPRNY4hIb4d3egStJEytkalDhB3sOebF57tIaCssg="
|
2
9
|
rvm:
|
3
|
-
- 2.
|
4
|
-
- 2.
|
10
|
+
- 2.2.10
|
11
|
+
- 2.3.8
|
12
|
+
- 2.4.9
|
13
|
+
- 2.5.7
|
14
|
+
- 2.6.5
|
15
|
+
- 2.7.0
|
16
|
+
- ruby-head
|
17
|
+
gemfile:
|
18
|
+
- gemfiles/rails42.gemfile
|
19
|
+
- gemfiles/rails50.gemfile
|
20
|
+
- gemfiles/rails51.gemfile
|
21
|
+
- gemfiles/rails52.gemfile
|
22
|
+
- gemfiles/rails60.gemfile
|
23
|
+
- gemfiles/rails42_haml.gemfile
|
24
|
+
- gemfiles/rails50_haml.gemfile
|
25
|
+
- gemfiles/rails51_haml.gemfile
|
26
|
+
- gemfiles/rails52_haml.gemfile
|
27
|
+
- gemfiles/rails60_haml.gemfile
|
28
|
+
- gemfiles/rails42_boc.gemfile
|
29
|
+
- gemfiles/rails50_boc.gemfile
|
30
|
+
- gemfiles/rails51_boc.gemfile
|
31
|
+
- gemfiles/rails52_boc.gemfile
|
32
|
+
- gemfiles/rails60_boc.gemfile
|
33
|
+
- gemfiles/rack.gemfile
|
34
|
+
- gemfiles/rack_boc.gemfile
|
35
|
+
- gemfiles/pry09.gemfile
|
36
|
+
- gemfiles/pry010.gemfile
|
37
|
+
- gemfiles/pry011.gemfile
|
38
|
+
matrix:
|
39
|
+
fast_finish: true
|
40
|
+
allow_failures:
|
41
|
+
- rvm: ruby-head
|
42
|
+
- gemfile: gemfiles/pry010.gemfile
|
43
|
+
- gemfile: gemfiles/pry011.gemfile
|
44
|
+
exclude:
|
45
|
+
- rvm: 2.2.10
|
46
|
+
gemfile: gemfiles/rails60.gemfile
|
47
|
+
- rvm: 2.2.10
|
48
|
+
gemfile: gemfiles/rails60_boc.gemfile
|
49
|
+
- rvm: 2.2.10
|
50
|
+
gemfile: gemfiles/rails60_haml.gemfile
|
51
|
+
- rvm: 2.3.8
|
52
|
+
gemfile: gemfiles/rails42.gemfile
|
53
|
+
- rvm: 2.3.8
|
54
|
+
gemfile: gemfiles/rails42_boc.gemfile
|
55
|
+
- rvm: 2.3.8
|
56
|
+
gemfile: gemfiles/rails42_haml.gemfile
|
57
|
+
- rvm: 2.3.8
|
58
|
+
gemfile: gemfiles/rails60.gemfile
|
59
|
+
- rvm: 2.3.8
|
60
|
+
gemfile: gemfiles/rails60_boc.gemfile
|
61
|
+
- rvm: 2.3.8
|
62
|
+
gemfile: gemfiles/rails60_haml.gemfile
|
63
|
+
- rvm: 2.4.9
|
64
|
+
gemfile: gemfiles/rails42.gemfile
|
65
|
+
- rvm: 2.4.9
|
66
|
+
gemfile: gemfiles/rails42_boc.gemfile
|
67
|
+
- rvm: 2.4.9
|
68
|
+
gemfile: gemfiles/rails42_haml.gemfile
|
69
|
+
- rvm: 2.4.9
|
70
|
+
gemfile: gemfiles/rails60.gemfile
|
71
|
+
- rvm: 2.4.9
|
72
|
+
gemfile: gemfiles/rails60_boc.gemfile
|
73
|
+
- rvm: 2.4.9
|
74
|
+
gemfile: gemfiles/rails60_haml.gemfile
|
75
|
+
- rvm: 2.5.7
|
76
|
+
gemfile: gemfiles/rails42.gemfile
|
77
|
+
- rvm: 2.5.7
|
78
|
+
gemfile: gemfiles/rails42_boc.gemfile
|
79
|
+
- rvm: 2.5.7
|
80
|
+
gemfile: gemfiles/rails42_haml.gemfile
|
81
|
+
- rvm: 2.6.5
|
82
|
+
gemfile: gemfiles/rails42.gemfile
|
83
|
+
- rvm: 2.6.5
|
84
|
+
gemfile: gemfiles/rails42_boc.gemfile
|
85
|
+
- rvm: 2.6.5
|
86
|
+
gemfile: gemfiles/rails42_haml.gemfile
|
87
|
+
- rvm: 2.7.0
|
88
|
+
gemfile: gemfiles/rails42.gemfile
|
89
|
+
- rvm: 2.7.0
|
90
|
+
gemfile: gemfiles/rails42_boc.gemfile
|
91
|
+
- rvm: 2.7.0
|
92
|
+
gemfile: gemfiles/rails42_haml.gemfile
|
93
|
+
- rvm: ruby-head
|
94
|
+
gemfile: gemfiles/rails42.gemfile
|
95
|
+
- rvm: ruby-head
|
96
|
+
gemfile: gemfiles/rails42_boc.gemfile
|
97
|
+
- rvm: ruby-head
|
98
|
+
gemfile: gemfiles/rails42_haml.gemfile
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/LICENSE.txt
CHANGED
data/README.md
CHANGED
@@ -1,15 +1,24 @@
|
|
1
|
-
|
1
|
+
[![Build Status](https://travis-ci.org/BetterErrors/better_errors.svg)](https://travis-ci.org/BetterErrors/better_errors)
|
2
|
+
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/6bc3e7d6118d47e6959b16690b815909)](https://www.codacy.com/app/BetterErrors/better_errors?utm_source=github.com&utm_medium=referral&utm_content=BetterErrors/better_errors&utm_campaign=Badge_Grade)
|
3
|
+
[![Coverage](https://coveralls.io/repos/github/BetterErrors/better_errors/badge.svg?branch=master)](https://coveralls.io/github/BetterErrors/better_errors?branch=master)
|
4
|
+
[![Gem Version](https://img.shields.io/gem/v/better_errors.svg)](https://rubygems.org/gems/better_errors)
|
5
|
+
|
6
|
+
# Better Errors
|
2
7
|
|
3
8
|
Better Errors replaces the standard Rails error page with a much better and more useful error page. It is also usable outside of Rails in any Rack app as Rack middleware.
|
4
9
|
|
5
|
-
![
|
10
|
+
![screenshot of Better Errors in action](https://i.imgur.com/6zBGAAb.png)
|
6
11
|
|
7
12
|
## Features
|
8
13
|
|
14
|
+
For screenshots of these features, [see the wiki](https://github.com/BetterErrors/better_errors/wiki).
|
15
|
+
|
9
16
|
* Full stack trace
|
10
17
|
* Source code inspection for all stack frames (with highlighting)
|
11
18
|
* Local and instance variable inspection
|
12
|
-
* Live REPL on every stack frame
|
19
|
+
* Live shell (REPL) on every stack frame
|
20
|
+
* Links directly to the source line in your editor
|
21
|
+
* Useful information in non-HTML requests
|
13
22
|
|
14
23
|
## Installation
|
15
24
|
|
@@ -18,71 +27,68 @@ Add this to your Gemfile:
|
|
18
27
|
```ruby
|
19
28
|
group :development do
|
20
29
|
gem "better_errors"
|
30
|
+
gem "binding_of_caller"
|
21
31
|
end
|
22
32
|
```
|
23
33
|
|
24
|
-
|
34
|
+
[`binding_of_caller`](https://github.com/banister/binding_of_caller) is optional, but is necessary to use Better Errors' advanced features (REPL, local/instance variable inspection, pretty stack frame names).
|
25
35
|
|
26
|
-
|
27
|
-
gem "binding_of_caller"
|
28
|
-
```
|
36
|
+
_Note: If you discover that Better Errors isn't working - particularly after upgrading from version 0.5.0 or less - be sure to set `config.consider_all_requests_local = true` in `config/environments/development.rb`._
|
29
37
|
|
30
|
-
|
38
|
+
### Optional: Set `EDITOR`
|
31
39
|
|
32
|
-
|
40
|
+
For many reasons outside of Better Errors, you should have the `EDITOR` environment variable set to your preferred
|
41
|
+
editor.
|
42
|
+
Better Errors, like many other tools, will use that environment variable to show a link that opens your
|
43
|
+
editor to the file and line from the console.
|
33
44
|
|
34
|
-
|
45
|
+
By default the links will open TextMate-protocol links.
|
35
46
|
|
36
|
-
|
47
|
+
To see if your editor is supported or to set up a different editor, see [the wiki](https://github.com/BetterErrors/better_errors/wiki/Link-to-your-editor).
|
37
48
|
|
38
|
-
|
49
|
+
### Optional: Set `BETTER_ERRORS_INSIDE_FRAME`
|
39
50
|
|
40
|
-
|
51
|
+
If your application is running inside of an iframe, or if you have a Content Security Policy that disallows links
|
52
|
+
to other protocols, the editor links will not work.
|
41
53
|
|
42
|
-
|
43
|
-
|
44
|
-
```
|
54
|
+
To work around this set `BETTER_ERRORS_INSIDE_FRAME=1` in the environment, and the links will include `target=_blank`,
|
55
|
+
allowing the link to open regardless of the policy.
|
45
56
|
|
46
|
-
|
57
|
+
_This works because it opens the editor from a new browser tab, escaping from the restrictions of your site._
|
58
|
+
_Unfortunately it leaves behind an empty tab each time, so only use this if needed._
|
47
59
|
|
48
|
-
|
49
|
-
TRUSTED_IP=66.68.96.220 rails s
|
50
|
-
```
|
60
|
+
## Security
|
51
61
|
|
52
|
-
|
62
|
+
**NOTE:** It is *critical* you put better\_errors only in the **development** section of your Gemfile.
|
63
|
+
**Do NOT run better_errors in production, or on Internet-facing hosts.**
|
53
64
|
|
54
|
-
|
65
|
+
You will notice that the only machine that gets the Better Errors page is localhost, which means you get the default error page if you are developing on a remote host (or a virtually remote host, such as a Vagrant box).
|
66
|
+
Obviously, the REPL is not something you want to expose to the public, and there may be sensitive information available in the backtrace.
|
55
67
|
|
56
|
-
|
68
|
+
For more information on how to configure access, see [the wiki](https://github.com/BetterErrors/better_errors/wiki/Allowing-access-to-the-console).
|
57
69
|
|
58
70
|
## Usage
|
59
71
|
|
60
72
|
If you're using Rails, there's nothing else you need to do.
|
61
73
|
|
74
|
+
### Using without Rails.
|
75
|
+
|
62
76
|
If you're not using Rails, you need to insert `BetterErrors::Middleware` into your middleware stack, and optionally set `BetterErrors.application_root` if you'd like Better Errors to abbreviate filenames within your application.
|
63
77
|
|
64
|
-
|
78
|
+
For instructions for your specific middleware, [see the wiki](https://github.com/BetterErrors/better_errors/wiki/Non-Rails-frameworks).
|
65
79
|
|
66
|
-
|
67
|
-
require "sinatra"
|
68
|
-
require "better_errors"
|
69
|
-
|
70
|
-
configure :development do
|
71
|
-
use BetterErrors::Middleware
|
72
|
-
BetterErrors.application_root = __dir__
|
73
|
-
end
|
80
|
+
### Plain text requests
|
74
81
|
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
```
|
82
|
+
Better Errors will render a plain text error page when the request is an
|
83
|
+
`XMLHttpRequest` or when the `Accept` header does *not* include 'html'.
|
79
84
|
|
80
85
|
### Unicorn, Puma, and other multi-worker servers
|
81
86
|
|
82
|
-
Better Errors works by leaving a lot of context in server process memory.
|
83
|
-
you're using a web server that runs multiple "workers" it's likely that a second
|
87
|
+
Better Errors works by leaving a lot of context in server process memory.
|
88
|
+
If you're using a web server that runs multiple "workers" it's likely that a second
|
84
89
|
request (as happens when you click on a stack frame) will hit a different
|
85
|
-
worker.
|
90
|
+
worker.
|
91
|
+
That worker won't have the necessary context in memory, and you'll see
|
86
92
|
a `Session Expired` message.
|
87
93
|
|
88
94
|
If this is the case for you, consider turning the number of workers to one (1)
|
@@ -90,10 +96,64 @@ in `development`. Another option would be to use Webrick, Mongrel, Thin,
|
|
90
96
|
or another single-process server as your `rails server`, when you are trying
|
91
97
|
to troubleshoot an issue in development.
|
92
98
|
|
99
|
+
### Changing the link to your editor
|
100
|
+
|
101
|
+
Better Errors includes a link to your editor for the file and line of code that is being shown.
|
102
|
+
By default, it uses your environment to determine which editor should be opened.
|
103
|
+
See [the wiki for instructions on configuring the editor](https://github.com/BetterErrors/better_errors/wiki/Link-to-your-editor).
|
104
|
+
|
105
|
+
|
106
|
+
## Set maximum variable size for inspector.
|
107
|
+
|
108
|
+
```ruby
|
109
|
+
# e.g. in config/initializers/better_errors.rb
|
110
|
+
# This will stop BetterErrors from trying to render larger objects, which can cause
|
111
|
+
# slow loading times and browser performance problems. Stated size is in characters and refers
|
112
|
+
# to the length of #inspect's payload for the given object. Please be aware that HTML escaping
|
113
|
+
# modifies the size of this payload so setting this limit too precisely is not recommended.
|
114
|
+
# default value: 100_000
|
115
|
+
BetterErrors.maximum_variable_inspect_size = 100_000
|
116
|
+
```
|
117
|
+
|
118
|
+
## Ignore inspection of variables with certain classes.
|
119
|
+
|
120
|
+
```ruby
|
121
|
+
# e.g. in config/initializers/better_errors.rb
|
122
|
+
# This will stop BetterErrors from trying to inspect objects of these classes, which can cause
|
123
|
+
# slow loading times and unneccessary database queries. Does not check inheritance chain, use
|
124
|
+
# strings not contants.
|
125
|
+
# default value: ['ActionDispatch::Request', 'ActionDispatch::Response']
|
126
|
+
BetterErrors.ignored_classes = ['ActionDispatch::Request', 'ActionDispatch::Response']
|
127
|
+
```
|
128
|
+
|
93
129
|
## Get in touch!
|
94
130
|
|
95
131
|
If you're using better_errors, I'd love to hear from you. Drop me a line and tell me what you think!
|
96
132
|
|
133
|
+
## Development
|
134
|
+
|
135
|
+
After checking out the repo, run `bundle install` to install the basic dependencies.
|
136
|
+
|
137
|
+
You can run the tests with the simplest set of dependencies using:
|
138
|
+
|
139
|
+
```rb
|
140
|
+
bundle exec rspec
|
141
|
+
```
|
142
|
+
|
143
|
+
To run specs for each of the dependency combinations, run:
|
144
|
+
|
145
|
+
```rb
|
146
|
+
bundle exec rake test:all
|
147
|
+
```
|
148
|
+
|
149
|
+
You can run specs for a specific dependency combination using:
|
150
|
+
|
151
|
+
```rb
|
152
|
+
BUNDLE_GEMFILE=gemfiles/pry09.gemfile bundle exec rspec
|
153
|
+
```
|
154
|
+
|
155
|
+
On CI, the specs are run against each gemfile on each supported version of Ruby.
|
156
|
+
|
97
157
|
## Contributing
|
98
158
|
|
99
159
|
1. Fork it
|
data/better_errors.gemspec
CHANGED
@@ -9,20 +9,39 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = ["charlie@charliesomerville.com"]
|
10
10
|
s.description = %q{Provides a better error page for Rails and other Rack apps. Includes source code inspection, a live REPL and local/instance variable inspection for all stack frames.}
|
11
11
|
s.summary = %q{Better error page for Rails and other Rack apps}
|
12
|
-
s.homepage = "https://github.com/
|
12
|
+
s.homepage = "https://github.com/BetterErrors/better_errors"
|
13
13
|
s.license = "MIT"
|
14
14
|
|
15
|
-
s.files = `git ls-files`.split(
|
16
|
-
|
15
|
+
s.files = `git ls-files -z`.split("\x0").reject do |f|
|
16
|
+
f.match(%r{^((test|spec|features|feature-screenshots)/|Rakefile)})
|
17
|
+
end
|
18
|
+
|
17
19
|
s.require_paths = ["lib"]
|
18
20
|
|
19
21
|
s.required_ruby_version = ">= 2.0.0"
|
20
22
|
|
21
|
-
s.
|
23
|
+
s.add_development_dependency "rake", "~> 10.0"
|
24
|
+
s.add_development_dependency "rspec", "~> 3.5"
|
25
|
+
s.add_development_dependency "rspec-html-matchers"
|
26
|
+
s.add_development_dependency "rspec-its"
|
27
|
+
s.add_development_dependency "yard"
|
28
|
+
# kramdown 2.1 requires Ruby 2.3+
|
29
|
+
s.add_development_dependency "kramdown", (RUBY_VERSION < '2.3' ? '< 2.0.0' : '> 2.0.0')
|
30
|
+
# simplecov and coveralls must not be included here. See the Gemfiles instead.
|
31
|
+
|
32
|
+
s.add_dependency "erubi", ">= 1.0.0"
|
22
33
|
s.add_dependency "coderay", ">= 1.0.0"
|
23
34
|
s.add_dependency "rack", ">= 0.9.0"
|
24
35
|
|
25
36
|
# optional dependencies:
|
26
37
|
# s.add_dependency "binding_of_caller"
|
27
38
|
# s.add_dependency "pry"
|
39
|
+
|
40
|
+
if s.respond_to?(:metadata)
|
41
|
+
s.metadata['changelog_uri'] = 'https://github.com/BetterErrors/better_errors/releases'
|
42
|
+
s.metadata['source_code_uri'] = 'https://github.com/BetterErrors/better_errors'
|
43
|
+
s.metadata['bug_tracker_uri'] = 'https://github.com/BetterErrors/better_errors/issues'
|
44
|
+
else
|
45
|
+
puts "Your RubyGems does not support metadata. Update if you'd like to make a release."
|
46
|
+
end
|
28
47
|
end
|