exception_handler 0.4.7 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.gitignore +11 -0
- data/.rspec +3 -1
- data/Gemfile +1 -1
- data/README.md +241 -92
- data/app/controllers/exception_handler/exception_controller.rb +13 -44
- data/app/helpers/exception_handler/application_helper.rb +47 -23
- data/app/models/exception_handler/error.rb +10 -9
- data/app/services/exception_handler/exception.rb +34 -0
- data/app/views/exception_handler/exception/show.html.erb +9 -6
- data/app/views/layouts/exception.html.erb +3 -3
- data/config/locales/en.yml +9 -0
- data/exception_handler.gemspec +16 -6
- data/lib/exception_handler.rb +67 -32
- data/lib/exception_handler/config.rb +49 -46
- data/lib/exception_handler/parse.rb +17 -17
- data/lib/exception_handler/parser/data.rb +57 -51
- data/lib/exception_handler/parser/ignore.rb +23 -23
- data/lib/exception_handler/version.rb +1 -1
- data/lib/generators/exception_handler/migration_generator.rb +17 -17
- data/lib/generators/exception_handler/views_generator.rb +27 -27
- data/spec/database.yml +3 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/config/manifest.js +4 -0
- data/spec/dummy/app/assets/images/.keep +0 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/javascripts/cable.coffee +11 -0
- data/spec/dummy/app/assets/javascripts/channels/.keep +0 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -0
- data/spec/dummy/app/channels/application_cable/channel.rb +5 -0
- data/spec/dummy/app/channels/application_cable/connection.rb +5 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/controllers/concerns/.keep +0 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/jobs/application_job.rb +2 -0
- data/spec/dummy/app/mailers/application_mailer.rb +4 -0
- data/spec/dummy/app/models/application_record.rb +3 -0
- data/spec/dummy/app/models/concerns/.keep +0 -0
- data/spec/dummy/app/views/layouts/application.html.erb +15 -0
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -0
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/bin/setup +34 -0
- data/spec/dummy/bin/update +29 -0
- data/spec/dummy/config.ru +8 -0
- data/spec/dummy/config/application.rb +21 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/cable.yml +10 -0
- data/spec/dummy/config/database.yml +25 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +62 -0
- data/spec/dummy/config/environments/production.rb +87 -0
- data/spec/dummy/config/environments/test.rb +42 -0
- data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +6 -0
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -0
- data/spec/dummy/config/initializers/assets.rb +11 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/callback_terminator.rb +6 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +4 -0
- data/spec/dummy/config/initializers/per_form_csrf_tokens.rb +4 -0
- data/spec/dummy/config/initializers/request_forgery_protection.rb +4 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/puma.rb +47 -0
- data/spec/dummy/config/routes.rb +6 -0
- data/spec/dummy/config/secrets.yml +22 -0
- data/spec/dummy/lib/assets/.keep +0 -0
- data/spec/dummy/log/.keep +0 -0
- data/spec/dummy/public/404.html +67 -0
- data/spec/dummy/public/422.html +67 -0
- data/spec/dummy/public/500.html +66 -0
- data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
- data/spec/dummy/public/apple-touch-icon.png +0 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/exception_handler.rb +22 -0
- data/spec/helpers/exception_handler/application_helper_spec.rb +42 -0
- data/spec/spec_helper.rb +28 -9
- metadata +102 -39
- data/readme/400.jpg +0 -0
- data/readme/500.jpg +0 -0
- data/readme/application_controller.jpg +0 -0
- data/readme/config.jpg +0 -0
- data/readme/db.jpg +0 -0
- data/readme/db_edit.jpg +0 -0
- data/readme/dev.jpg +0 -0
- data/readme/exception_controller.jpg +0 -0
- data/readme/exceptions_app.png +0 -0
- data/readme/layout.jpg +0 -0
- data/readme/parser.jpg +0 -0
- data/readme/rubygems.jpg +0 -0
- data/readme/source/screen.psd +0 -0
- data/readme/source/subtitle.psd +0 -0
- data/readme/source/title.psd +0 -0
- data/readme/subtitle.jpg +0 -0
- data/readme/title.jpg +0 -0
- data/readme/titles/bugs.png +0 -0
- data/readme/titles/contents.png +0 -0
- data/readme/titles/contribution.png +0 -0
- data/readme/titles/custom_error_pages.png +0 -0
- data/readme/titles/support.png +0 -0
- data/readme/titles/testing.png +0 -0
- data/readme/titles/title.psd +0 -0
- data/readme/view.jpg +0 -0
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA1:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 8c229b37921ac22e8324f72d64e9e3b5278057f3
|
|
4
|
+
data.tar.gz: 5e858de7ce25556d18bb5abba14864193e0d1d7b
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: af0923ee9aff4299876616cbd7dfda47669b91e77073e80182bc617c86949332229ac152d98ee7604a63f8827df19db216c5851ac8b346a8a280bdb26cd27a4a
|
|
7
|
+
data.tar.gz: 6df51af9f68cfaece304c42327487119fe1e4c966e1e7867e2c95c623e1dcf4e2945c627d316b01ec5f679b760b48096b1472b92eddd937bd4d61309a7fe086f
|
data/.gitignore
CHANGED
|
@@ -20,3 +20,14 @@ tmp
|
|
|
20
20
|
*.o
|
|
21
21
|
*.a
|
|
22
22
|
mkmf.log
|
|
23
|
+
*.tmp
|
|
24
|
+
|
|
25
|
+
# http://stackoverflow.com/questions/8865848/comments-in-gitignore
|
|
26
|
+
# https://gist.github.com/danielpcox/4636520
|
|
27
|
+
|
|
28
|
+
log/*.log
|
|
29
|
+
pkg/
|
|
30
|
+
spec/dummy/db/*.sqlite3
|
|
31
|
+
spec/dummy/log/*.log
|
|
32
|
+
spec/dummy/tmp/
|
|
33
|
+
spec/dummy/.sass-cache
|
data/.rspec
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|

|
|
2
2
|
|
|
3
|
+
<p align="center">
|
|
4
|
+
<strong><a href="#user-content-install">Install</a></strong> - <strong><a href="#user-content-config">Config</a></strong> - <strong><a href="#user-content-support">Support</a></strong>
|
|
5
|
+
</p>
|
|
6
|
+
|
|
3
7
|
<p align="center">
|
|
4
8
|
<a href="http://badge.fury.io/rb/exception_handler"><img src="https://badge.fury.io/rb/exception_handler.svg"></a>
|
|
5
9
|
<a href="https://codeclimate.com/github/richpeck/exception_handler"><img src="https://codeclimate.com/github/richpeck/exception_handler.png"></a>
|
|
@@ -10,170 +14,315 @@
|
|
|
10
14
|
|
|
11
15
|
----------
|
|
12
16
|
|
|
13
|
-
**ExceptionHandler** helps you can create custom **404 & 500 production error pages** *(adapted from [**1**](https://gist.github.com/wojtha/8433843) & [**2**](http://www.sharagoz.com/posts/1-rolling-your-own-exception-handler-in-rails-3))
|
|
17
|
+
**ExceptionHandler** helps you can create custom **404 & 500 production error pages** *(adapted from [**1**](https://gist.github.com/wojtha/8433843) & [**2**](http://www.sharagoz.com/posts/1-rolling-your-own-exception-handler-in-rails-3))*.
|
|
14
18
|
|
|
15
19
|

|
|
16
20
|
|
|
21
|
+
**ExceptionHandler** is the *only* production-ready custom error page solution for Rails 4 & 5.
|
|
22
|
+
|
|
23
|
+
---
|
|
24
|
+
|
|
17
25
|
<p align="center">
|
|
18
|
-
<img src="/readme/
|
|
26
|
+
<br /><img src="/readme/05_title.png" width="450" /><br/>
|
|
27
|
+
<strong>Customize <i>404</i> and <i>500</i> error pages to be branded to your application in production:</strong>
|
|
19
28
|
</p>
|
|
20
29
|
|
|
30
|
+
<p align="center">
|
|
31
|
+
<img src="/readme/check.png" height="22" title="Fully Responsive" align="absmiddle" /> <strong>Responsive</strong>
|
|
32
|
+
<img src="/readme/check.png" height="22" title="Branded Error Pages" align="absmiddle" /> <strong>Branded Error Pages</strong>
|
|
33
|
+
<img src="/readme/check.png" height="22" title="Middleware Exception Handling" align="absmiddle" /> <strong>Middleware Exception Handling</strong>
|
|
34
|
+
<img src="/readme/check.png" height="22" title="Keep Users Informed" align="absmiddle" /> <strong>Fully Customizable</strong>
|
|
35
|
+
</p>
|
|
36
|
+
|
|
37
|
+
<p align="center">
|
|
38
|
+
<img src="/readme/branded/1.jpg" width="425" title="Fully Branded Error Pages" /> <img src="/readme/branded/2.jpg" width="425" title="Fully Branded Error Pages" />
|
|
39
|
+
<img src="/readme/branded/3.jpg" width="425" title="Fully Branded Error Pages" /> <img src="/readme/branded/4.jpg" width="425" title="Fully Branded Error Pages" />
|
|
40
|
+
</p>
|
|
41
|
+
|
|
42
|
+
The most feature-rich, stable & effective solution for **custom error pages** in Rails 4 & 5.
|
|
43
|
+
|
|
21
44
|
---
|
|
22
45
|
|
|
23
|
-
|
|
46
|
+
<p align="center">
|
|
47
|
+
<img src="readme/05.jpg" title="Reworked for Rails 5" />
|
|
48
|
+
</p>
|
|
24
49
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
**layouts/application.html.erb** | **layouts/errors.html.erb**
|
|
50
|
+
<p align="center">
|
|
51
|
+
<img src="readme/titles/reworked.jpg" title="Reworked for Rails 5" width="450" />
|
|
52
|
+
</p>
|
|
29
53
|
|
|
54
|
+
<p align="center">
|
|
55
|
+
<img src="/readme/check_02.png" height="22" title="New Controller" align="absmiddle" /> <strong>New Controller</strong>
|
|
56
|
+
<img src="/readme/check_02.png" height="22" title="New Middleware" align="absmiddle" /> <strong>New Middleware</strong>
|
|
57
|
+
<img src="/readme/check_02.png" height="22" title="Full Test Suite" align="absmiddle" /> <strong>Full Test Suite</strong>
|
|
58
|
+
<img src="/readme/check_02.png" height="22" title="Rails 4 & 5 Compatible" align="absmiddle" /> <strong>FULLY Rails 4 & 5 Compatible</strong>
|
|
59
|
+
</p>
|
|
30
60
|
|
|
31
|
-
|
|
61
|
+
Brand new `controller`, `middleware` & options have made **`ExceptionHandler`** even more powerful & efficient. Now you can use `ExceptionHandler` directly with a single click -- **plug and play** custom exception pages:
|
|
32
62
|
|
|
33
|
-
|
|
63
|
+
<div align="center">
|
|
64
|
+
<img src="/readme/400.jpg" title="400 Errors" width="435" />
|
|
65
|
+
<img src="/readme/500.jpg" title="500 Errors" width="435" />
|
|
66
|
+
</div>
|
|
34
67
|
|
|
35
|
-
|
|
68
|
+
**ExceptionHandler** uses `config.exceptions_app` to catch & send errors to the [`exceptions` controller](app/controllers/exception_handler/exception_controller.rb).
|
|
36
69
|
|
|
37
|
-
|
|
70
|
+
It uses data stored in `Rack` (`message`, `details`, `user agent`) to populate its `custom view`. This gives you the ability to **maintain your branding** *even* when your app experiences an exception.
|
|
38
71
|
|
|
39
|
-
|
|
72
|
+
----
|
|
40
73
|
|
|
41
|
-
<
|
|
74
|
+
<p align="center">
|
|
75
|
+
<br />
|
|
76
|
+
<img src="/readme/titles/middleware.jpg" title="Middleware Powered Exceptions" width="300" />
|
|
77
|
+
<br />
|
|
78
|
+
</p>
|
|
79
|
+
|
|
80
|
+
The power of **`ExceptionHandler`** lies in its capacity to access the [**`ActiveDispatch::ShowExceptions`**](https://github.com/rails/rails/blob/4-0-stable/actionpack/lib/action_dispatch/middleware/show_exceptions.rb) middleware:
|
|
81
|
+
|
|
82
|
+
<p align="center">
|
|
83
|
+
<img src="/readme/middleware.jpg" title="Exceptions handled by the ActiveDispatch::ShowExceptions Middleware" />
|
|
84
|
+
</p>
|
|
85
|
+
|
|
86
|
+
Rails invokes [`config.exceptions_app`](http://guides.rubyonrails.org/configuring.html#rails-general-configuration) whenever an exception is raised.
|
|
87
|
+
|
|
88
|
+
**ExceptionHandler** injects our `ExceptionController` into this hook to provide the most efficient response:
|
|
89
|
+
|
|
90
|
+
> **`config.exceptions_app`** sets the exceptions application invoked by the **`ShowException`** middleware when an exception happens. Defaults to **`ActionDispatch::PublicExceptions.new(Rails.public_path)`**.
|
|
42
91
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
-
|
|
51
|
-
|
|
92
|
+
<p align="center">
|
|
93
|
+
<img src="readme/exceptions_app.jpg" title="Exceptions App" />
|
|
94
|
+
</p>
|
|
95
|
+
|
|
96
|
+
As opposed to other exception suites (which use the `routes`), this gives you DIRECT access to the exception through the middleware stack, straight to the [`ExceptionController`](/app/controllers/exception_handler/exception_controller.rb):
|
|
97
|
+
|
|
98
|
+
<p align="center">
|
|
99
|
+
<img src="readme/controller_middleware.jpg" title="ExceptionsController compiles the exception & delivers to the front-end" />
|
|
100
|
+
</p>
|
|
101
|
+
|
|
102
|
+
**ExceptionHandler** uses [custom middleware](https://github.com/richpeck/exception_handler/blob/0.5/lib/exception_handler/parse.rb) to extract *all* the exception data for the request. Not only is this the most succinct, efficient way to do this, it also allows you to customize the *entire* fault-recovery process.
|
|
103
|
+
|
|
104
|
+
It's completely unique - the **only** professional solution to catch, process & handle exceptions in Rails.
|
|
52
105
|
|
|
53
106
|
----------
|
|
54
107
|
|
|
55
|
-
|
|
108
|
+
<p align="center" id="install">
|
|
109
|
+
<br />
|
|
110
|
+
<img src="readme/titles/install.jpg" title="1 Click Install for ExceptionHandler 5 on Rails 5" width="350" />
|
|
111
|
+
<br />
|
|
112
|
+
<strong>You Don't Need <i>Any</i> Configuration To Run ExceptionHandler</strong>
|
|
113
|
+
</p>
|
|
114
|
+
|
|
115
|
+
gem install "exception_handler"
|
|
116
|
+
|
|
117
|
+
or
|
|
56
118
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
or
|
|
119
|
+
gem 'exception_handler', '~> 0.5.0' #-> Gemfile
|
|
60
120
|
|
|
61
|
-
|
|
121
|
+
`ExceptionHandler`'s new **config** system (introduced in [`0.4.7`](https://github.com/richpeck/exception_handler/wiki/Setup)) stores all the [defaults](#user-content-defaults) - you just need to install the gem & let it run.
|
|
62
122
|
|
|
63
|
-
|
|
64
|
-
|
|
123
|
+
If you want to change *any* settings (detailed [below](#user-content-config)), you **simply** need to change `config/application.rb` / `config/environments/your_env.rb`. The ***POWER*** of this *new config system* means you're able to deploy `ExceptionHandler` in the most unobtrusive, versatile way possible.
|
|
124
|
+
|
|
125
|
+
<p align="center">
|
|
126
|
+
<a href="http://rubygems.org/gems/exception_handler" target="_blank">
|
|
127
|
+
<img src="/readme/rubygems.jpg" title="30,000+ Downloads Through RubyGems" />
|
|
128
|
+
<br />
|
|
129
|
+
</a>
|
|
130
|
+
</p>
|
|
131
|
+
|
|
132
|
+
----
|
|
133
|
+
|
|
134
|
+
<p align="center" id="config">
|
|
65
135
|
<br />
|
|
66
|
-
<img src="
|
|
67
|
-
</
|
|
136
|
+
<img src="readme/titles/config.jpg" title="Instant Custom Error Pages For Rails 4 & 5" width="325" />
|
|
137
|
+
</p>
|
|
68
138
|
|
|
69
|
-
|
|
139
|
+
**`ExceptionHandler 0.5`** has the SIMPLEST config possible...
|
|
70
140
|
|
|
71
|
-
|
|
141
|
+
<p align="center">
|
|
142
|
+
<img src="/readme/config_defaults.jpg" title="ExceptionHandler Default Configuration Options">
|
|
143
|
+
</p>
|
|
72
144
|
|
|
73
|
-
|
|
145
|
+
The MAGIC is that it uses [`environment files`](http://guides.rubyonrails.org/configuring.html#creating-rails-environments).
|
|
74
146
|
|
|
75
|
-
|
|
147
|
+
You can apply the above options to any of Rails' environment files, allowing you to customize the `ExceptionHandler` gem without inducing ANY overhead. `Initializer` files just get in the way.
|
|
76
148
|
|
|
149
|
+
> **IMPORTANT**
|
|
150
|
+
>
|
|
151
|
+
> If you're upgrading from >= `0.4.7`, you need to **remove your `exception_handler` initializer**.
|
|
152
|
+
>
|
|
153
|
+
> We've changed the load process to use Rails app config - **you don't need the `exception_handler` initializer any more**
|
|
77
154
|
|
|
78
|
-
|
|
155
|
+
----
|
|
79
156
|
|
|
80
|
-
|
|
157
|
+
<br />
|
|
158
|
+
<img src="readme/titles/defaults.jpg" title="Defaults" id="defaults" />
|
|
81
159
|
|
|
82
|
-
|
|
160
|
+
As can be seen in the [`config class`](/lib/exception_handler/config.rb), the following are all the options `exception_handler` accepts:
|
|
83
161
|
|
|
84
|
-
|
|
162
|
+
<p align="center">
|
|
163
|
+
<img src="/readme/defaults.jpg" title="ExceptionHandler Default Configuration Options">
|
|
164
|
+
</p>
|
|
85
165
|
|
|
86
|
-
|
|
166
|
+
# config.rb
|
|
167
|
+
DEFAULTS = {
|
|
168
|
+
dev: false, #-> defaults to "false" for dev mode
|
|
169
|
+
db: false, #-> defaults to :errors if true, else input "table_name" as string
|
|
170
|
+
email: false, #-> need to integrate
|
|
171
|
+
social: {
|
|
172
|
+
:facebook => 'frontline.utilities', #-> Facebook handle
|
|
173
|
+
:twitter => 'frontlineutils', #-> Twitter handle
|
|
174
|
+
:youtube => 'frontlineutils', #-> YouTube handle
|
|
175
|
+
:linkedin => 'frontline-utilities', #-> LinkedIn handle
|
|
176
|
+
:fusion => 'frontlineutils', #-> Fusion handle
|
|
177
|
+
:url => {
|
|
178
|
+
:facebook => 'https://facebook.com', #-> no need to edit
|
|
179
|
+
:twitter => 'http://twitter.com', #-> no need to edit
|
|
180
|
+
:youtube => 'https://youtube.com/user', #-> no need to edit
|
|
181
|
+
:linkedin => 'https://linkedin.com/company', #-> no need to edit
|
|
182
|
+
:fusion => 'https://frontlinefusion.com', #-> no need to edit
|
|
183
|
+
},
|
|
184
|
+
},
|
|
185
|
+
layouts: {
|
|
186
|
+
'404' => nil, #-> 404 Callback (needs improving big time) Use the following: '404' => <<-EOF redirect_to root_url, notice: "Hello" EOF
|
|
187
|
+
'400' => nil, #-> layout for 400 error code (404 should only be used as response)
|
|
188
|
+
'500' => 'exception'
|
|
189
|
+
},
|
|
190
|
+
}
|
|
87
191
|
|
|
88
|
-
|
|
192
|
+
The above are ***defaults***.
|
|
89
193
|
|
|
90
|
-
|
|
91
|
-
$ rake db:migrate
|
|
194
|
+
You can change the options for each [`environment file`](http://guides.rubyonrails.org/configuring.html#creating-rails-environments):
|
|
92
195
|
|
|
93
|
-
|
|
196
|
+
- `config/application.rb`
|
|
197
|
+
- `config/environments/development.rb`
|
|
198
|
+
- `config/environments/production.rb`
|
|
199
|
+
- `config/environments/staging.rb`
|
|
94
200
|
|
|
95
|
-
|
|
201
|
+
The benefit of this is that it gives you the ability to customize `ExceptionHandler` for any of your environments. Contrary to a shitty `initializer`, you're able to sculpt the gem to work FOR YOU.
|
|
96
202
|
|
|
97
|
-
|
|
203
|
+
----
|
|
98
204
|
|
|
99
|
-
|
|
205
|
+
<br />
|
|
206
|
+
<img src="readme/titles/dev.jpg" title="Development Mode (New!!!)" id="dev" />
|
|
100
207
|
|
|
101
|
-
|
|
208
|
+
Want to test in the `dev` environment?
|
|
102
209
|
|
|
103
|
-
|
|
210
|
+
#config/application.rb
|
|
211
|
+
config.exception_handler = {
|
|
212
|
+
dev: true # -> Runs in development mode WITHOUT changing the app environment files
|
|
213
|
+
}
|
|
104
214
|
|
|
105
|
-
|
|
106
|
-
$ rails generate exception_handler:views -v views controllers models helpers assets #-> remove as appropriate to install individual assets
|
|
215
|
+
<img src="/readme/dev.jpg" title="ExceptionHandler Dev Mode - NEW!!!!!">
|
|
107
216
|
|
|
108
|
-
|
|
217
|
+
[`config.exceptions_app`](http://guides.rubyonrails.org/configuring.html#rails-general-configuration) *only* works when you have [`config.consider_all_requests_local = true`](http://blog.bigbinary.com/2009/02/05/rescue_action_in_public-local_request-and-how-to-configure-local_request.html), which is `true` in `development`:
|
|
109
218
|
|
|
110
|
-
|
|
219
|
+
> **`config.consider_all_requests_local`** is a flag. If true then any error will cause detailed debugging information to be dumped in the `HTTP` response, and the `Rails::Info controller` will show the application runtime context in `/rails/info/properties`. `True` by default in development and test environments, and false in production mode. For finer-grained control, set this to false and implement `local_request?` in controllers to specify which requests should provide debugging information on errors.
|
|
220
|
+
|
|
221
|
+
|
|
222
|
+
If you wish to test **`ExceptionHandler`** in `development`, you'll have to use the `dev: true` option in your `exception_handler` config, *or* change `config.consider_all_requests_local = true` in `config/development.rb`.
|
|
111
223
|
|
|
112
|
-
|
|
224
|
+
----
|
|
113
225
|
|
|
114
|
-
|
|
226
|
+
<br />
|
|
227
|
+
<img src="readme/titles/layout.jpg" title="Layout" id="layout" />
|
|
115
228
|
|
|
116
|
-
|
|
229
|
+
One of the most critial aspects of **`ExceptionHandler`** is the custom `Exception` layout.
|
|
230
|
+
|
|
231
|
+
If you want to change the layout (for `500` error pages), you need to use the following:
|
|
232
|
+
|
|
233
|
+
<img src="readme/layout.jpg" title="Custom Exceptions Layout For ExceptionHandler" />
|
|
234
|
+
|
|
235
|
+
You'll need to [generate](#user-content-view) it into your application before being able to edit:
|
|
236
|
+
|
|
237
|
+
----
|
|
238
|
+
|
|
239
|
+
<br />
|
|
240
|
+
<img src="readme/titles/view.jpg" title="Views" id="view" />
|
|
241
|
+
|
|
242
|
+
**`ExceptionHandler`** comes with its own inbuilt views & controller.
|
|
243
|
+
|
|
244
|
+
If you want to change it, you need to add the views into your app with the [`generator`](/lib/generators/exception_handler/views_generator.rb)
|
|
245
|
+
|
|
246
|
+
$ rails generate exception_handler:views #-> controller, models, helpers, views & assets
|
|
247
|
+
$ rails generate exception_handler:views -v views controllers models helpers assets #-> remove as appropriate to install individual assets
|
|
248
|
+
|
|
249
|
+
--
|
|
250
|
+
|
|
251
|
+
<img src="readme/show.jpg" title="ExceptionHandler Show view" />
|
|
252
|
+
|
|
253
|
+
`ExceptionHandler` uses `exceptions#show` -- located in **`app/views/exception_handler/show.html.erb`** designed to work for all exceptions.
|
|
117
254
|
|
|
118
255
|
By default, it is split for use with different layouts, data being available to both.
|
|
119
256
|
|
|
120
|
-
This works exactly the same as the other views in your app (IE the `exceptions
|
|
257
|
+
This works exactly the same as the other views in your app (IE the `exceptions controller` invokes the `show` action)
|
|
121
258
|
|
|
122
|
-
|
|
259
|
+
----
|
|
123
260
|
|
|
124
|
-
|
|
261
|
+
<br />
|
|
262
|
+
<img src="readme/titles/db.jpg" title="Database" id="db" />
|
|
125
263
|
|
|
126
|
-
|
|
264
|
+
If you want to store exceptions in your `db`, you will need to set up a **migration**:
|
|
127
265
|
|
|
128
|
-
|
|
266
|
+
$ rails generate exception_handler:migration
|
|
267
|
+
$ rake db:migrate
|
|
129
268
|
|
|
130
|
-
|
|
269
|
+
You will also need to ensure your config db option is either `true` or `"table_name"`:
|
|
131
270
|
|
|
132
|
-
|
|
271
|
+
<img src="/readme/db.jpg" title="ExceptionHandler DB Config">
|
|
133
272
|
|
|
134
|
-
<img src="/readme/
|
|
273
|
+
<img src="/readme/db_screenshot.jpg" title="ExceptionHandler Database">
|
|
135
274
|
|
|
136
|
-
|
|
275
|
+
> **IMPORTANT**
|
|
276
|
+
>
|
|
277
|
+
> `ExceptionHandler`'s [new config system](https://github.com/richpeck/exception_handler/wiki/Setup) is `environment` agnostic.
|
|
278
|
+
>
|
|
279
|
+
> **Where you declare your `db` setting will change depending on your environment**
|
|
280
|
+
>
|
|
281
|
+
> If you declare `db` in `application.rb`, it will be applicable for all `environments`; only declaring in `production.rb` will set it for production *only*.
|
|
137
282
|
|
|
138
|
-
|
|
283
|
+
----
|
|
139
284
|
|
|
140
|
-
|
|
285
|
+
<p align="center" id="support">
|
|
286
|
+
<br />
|
|
287
|
+
<img src="readme/titles/support.jpg" title="1hr & 24 hr Support" width="225" />
|
|
288
|
+
</p>
|
|
141
289
|
|
|
142
|
-
|
|
290
|
+
Github Issue (1hr) | Stackoverflow (24hrs)
|
|
291
|
+
:----: | :----:
|
|
292
|
+
[](https://github.com/richpeck/exception_handler/issues) | [](http://stackoverflow.com/questions/ask?tags=ruby-on-rails+exception-handler)
|
|
143
293
|
|
|
144
|
-
|
|
294
|
+
We use **`ExceptionHandler`** in production, so we have a vested interest in keeping it running smoothly.
|
|
145
295
|
|
|
146
|
-
|
|
296
|
+
Asking in either of the above services will give you a response. Don't be shy, we want to make this the best `exception handling` middleware for Rails.
|
|
147
297
|
|
|
148
|
-
|
|
298
|
+
--
|
|
149
299
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
A significant issue exists in respect to the inheritance of `exceptions_controller`.
|
|
153
|
-
Our current version (`0.4`) inherits from the `ApplicationController`. This causes a problem for many applications.
|
|
300
|
+
<br />
|
|
301
|
+
<img src="readme/titles/changelog.jpg" title="Changelog" id="changelog" />
|
|
154
302
|
|
|
155
|
-
|
|
156
|
-
|
|
303
|
+
#### 0.5.1
|
|
304
|
+
- Next release
|
|
157
305
|
|
|
158
|
-
|
|
159
|
-
|
|
306
|
+
#### 0.5.0
|
|
307
|
+
- Added locales
|
|
308
|
+
- Email notifications
|
|
309
|
+
- Full test suite (finally)
|
|
310
|
+
- Rails 4.2 & Rails 5.0 native ([`request.env`](https://github.com/rails/rails/commit/05934d24aff62d66fc62621aa38dae6456e276be) fix)
|
|
311
|
+
- Controller fixed
|
|
312
|
+
- `DB` fixed
|
|
313
|
+
- Legacy initializer support ([more](https://github.com/richpeck/exception_handler/wiki/Setup))
|
|
314
|
+
- Rails asset management improvement
|
|
315
|
+
- Cut out most dev files from gem (drastic reduction in gem size)
|
|
160
316
|
|
|
161
317
|
|
|
162
|
-
|
|
318
|
+
#### 0.4.7
|
|
163
319
|
|
|
164
|
-
|
|
320
|
+
- New config system ([more](https://github.com/richpeck/exception_handler/wiki/Setup))
|
|
321
|
+
- Fixed controller layout issues
|
|
322
|
+
- Streamlined middleware
|
|
323
|
+
- New layout & interface implementation
|
|
165
324
|
|
|
166
|
-
- Watch the video tutorial (soon)
|
|
167
|
-
- [Create an "issue"](https://github.com/richpeck/exception_handler/issues)
|
|
168
|
-
- Contact support (soon)
|
|
169
|
-
- [Ask on StackOverflow](http://stackoverflow.com/questions/ask?tags=exception_handler&ruby_on_rails)
|
|
170
325
|
|
|
171
326
|
----------
|
|
172
327
|
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
1. Fork it ( https://github.com/richpeck/exception_handler/fork )
|
|
176
|
-
2. Create your feature branch (`git checkout -b my-new-feature`)
|
|
177
|
-
3. Commit your changes (`git commit -am 'Add some feature'`)
|
|
178
|
-
4. Push to the branch (`git push origin my-new-feature`)
|
|
179
|
-
5. Create a new Pull Request
|
|
328
|
+
© 2016 [**R Peck**](http://stackoverflow.com/users/1143732/richard-peck) for [**FL**](http://frontlineutilities.co.uk)
|