exception_handler 0.8.0.0 → 0.8.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/.coveralls.yml +1 -0
  3. data/.gitignore +1 -0
  4. data/.rspec +3 -3
  5. data/.travis.yml +6 -0
  6. data/README.md +327 -326
  7. data/app/views/layouts/exception.html.erb +1 -1
  8. data/app/views/layouts/mailer.html.erb +5 -5
  9. data/app/views/layouts/mailer.text.erb +1 -1
  10. data/config/locales/exception_handler.en.yml +1 -1
  11. data/config/routes.rb +42 -42
  12. data/exception_handler.gemspec +1 -0
  13. data/lib/exception_handler/version.rb +1 -1
  14. data/spec/controllers/controller_spec.rb +107 -107
  15. data/spec/dummy/Rakefile +6 -6
  16. data/spec/dummy/app/assets/config/manifest.js +3 -3
  17. data/spec/dummy/app/assets/javascripts/application.js +15 -15
  18. data/spec/dummy/app/assets/javascripts/cable.js +13 -13
  19. data/spec/dummy/app/assets/stylesheets/application.css +15 -15
  20. data/spec/dummy/app/channels/application_cable/channel.rb +4 -4
  21. data/spec/dummy/app/channels/application_cable/connection.rb +4 -4
  22. data/spec/dummy/app/controllers/application_controller.rb +2 -2
  23. data/spec/dummy/app/helpers/application_helper.rb +2 -2
  24. data/spec/dummy/app/jobs/application_job.rb +2 -2
  25. data/spec/dummy/app/mailers/application_mailer.rb +4 -4
  26. data/spec/dummy/app/models/application_record.rb +3 -3
  27. data/spec/dummy/app/views/layouts/application.html.erb +15 -15
  28. data/spec/dummy/app/views/layouts/mailer.html.erb +13 -13
  29. data/spec/dummy/app/views/layouts/mailer.text.erb +1 -1
  30. data/spec/dummy/bin/bundle +3 -3
  31. data/spec/dummy/bin/rails +4 -4
  32. data/spec/dummy/bin/rake +4 -4
  33. data/spec/dummy/bin/setup +36 -36
  34. data/spec/dummy/bin/update +31 -31
  35. data/spec/dummy/bin/yarn +11 -11
  36. data/spec/dummy/config.ru +5 -5
  37. data/spec/dummy/config/application.rb +18 -18
  38. data/spec/dummy/config/boot.rb +5 -5
  39. data/spec/dummy/config/cable.yml +10 -10
  40. data/spec/dummy/config/database.yml +25 -25
  41. data/spec/dummy/config/environment.rb +5 -5
  42. data/spec/dummy/config/environments/development.rb +61 -61
  43. data/spec/dummy/config/environments/production.rb +94 -94
  44. data/spec/dummy/config/environments/test.rb +46 -46
  45. data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -8
  46. data/spec/dummy/config/initializers/assets.rb +14 -14
  47. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
  48. data/spec/dummy/config/initializers/content_security_policy.rb +25 -25
  49. data/spec/dummy/config/initializers/cookies_serializer.rb +5 -5
  50. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
  51. data/spec/dummy/config/initializers/inflections.rb +16 -16
  52. data/spec/dummy/config/initializers/mime_types.rb +4 -4
  53. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
  54. data/spec/dummy/config/locales/en.yml +33 -33
  55. data/spec/dummy/config/puma.rb +34 -34
  56. data/spec/dummy/config/routes.rb +3 -3
  57. data/spec/dummy/config/storage.yml +34 -34
  58. data/spec/dummy/package.json +5 -5
  59. data/spec/dummy/public/404.html +67 -67
  60. data/spec/dummy/public/422.html +67 -67
  61. data/spec/dummy/public/500.html +66 -66
  62. data/spec/dummy/spec/rails_helper.rb +57 -57
  63. data/spec/features/asset_spec.rb +61 -61
  64. data/spec/features/config_spec.rb +51 -51
  65. data/spec/features/engine_spec.rb +180 -180
  66. data/spec/mailers/mailer_spec.rb +26 -0
  67. data/spec/models/model_spec.rb +26 -0
  68. data/spec/routing/routing_spec.rb +85 -85
  69. data/spec/spec_helper.rb +101 -93
  70. data/spec/views/views_spec.rb +29 -29
  71. metadata +22 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49e2fc9996c4c5b2d6f795f5e08214d8fcb6d8228b735416903da5bd0e149ac6
4
- data.tar.gz: 7c08ef59fa0f7766c07ce6da3c6a92d90dd543ad4c7bb1e3884289bd309e309d
3
+ metadata.gz: ba54148f25815a5f2df409c4261ade99ffa4f2f96c4a0ae354149ba539bffac3
4
+ data.tar.gz: ee20ae2ed6c8be539b8ffb0388da0b2680aaaaf5aa793a0df49fe38e5230ea2e
5
5
  SHA512:
6
- metadata.gz: 937f0e527726d0c0af814b16b9a276290dad5181eb482280d9ed9230bde06d8094a88ef9e8d5abe27656c86c593b20a7ffcde427c7d0782cd55ba7d7b3d1be2c
7
- data.tar.gz: 1ca6e353d9a05b023bcc2ca23321135cd7215b6a7be448d69979b698b309033a3c73d435678313f584fb8caac6e7eb48323ab2d7f73bcf62235a03df78ffb228
6
+ metadata.gz: e5a14eeb3beb2ffab2fe1289acd377423242d980294cf0872e85ba86aeb7165027de92b2057d034a1730ff4e38fb716b38052c81d1502143a658367e1a1ae23c
7
+ data.tar.gz: '0890e4e17d5bb8c94cefb0dc24adb8d40f7fc49c8c9cb7f4e6904221e61750dd23f886ce1af3141316f5dc14152e8ae6cabc1bd3285a90a6e5c3646d8fa7783d'
data/.coveralls.yml ADDED
@@ -0,0 +1 @@
1
+ service_name: travis-ci
data/.gitignore CHANGED
@@ -22,6 +22,7 @@ tmp
22
22
  mkmf.log
23
23
  *.tmp
24
24
  .rspec_status
25
+ /coverage/
25
26
 
26
27
  ##########################################################
27
28
  ##########################################################
data/.rspec CHANGED
@@ -1,3 +1,3 @@
1
- --format progress
2
- --color
3
- --require spec_helper
1
+ --format progress
2
+ --color
3
+ --require spec_helper
data/.travis.yml CHANGED
@@ -5,3 +5,9 @@ rvm:
5
5
  - 2.4.4
6
6
  - 2.5.1
7
7
  - ruby-head
8
+ notifications:
9
+ - false
10
+ scripts:
11
+ - bundle exec rspec
12
+ after_script:
13
+ - bundle exec rake coveralls:push
data/README.md CHANGED
@@ -1,179 +1,106 @@
1
- <p align="center">
2
- <strong>💣 README Currently Being Updated 💣 - Gem Incorporated into 💀 <a href="https://www.vpsdeploy.com" title="Custom VPS Deployment For Rails"><u>VPSDeploy.com - VPS Deployment Solution</u></a> 💀 -<br/><code>Custom Programming Tutorials</code> + <code>Deployment Infrastructure</code> For Cloud VPS Providers...</strong>
3
- </p>
4
- <hr />
5
-
6
1
  ![Exception Handler](readme/title.jpg "Exception Handler Logo")
7
2
 
8
- <p align="center">
9
- <img src="./readme/dev.png" /><br />
10
- </p>
11
-
12
- <p align="center">
13
- <img src="/readme/titles/initial.png" width="90%" />
14
- </p>
15
-
16
- <p align="center">
17
- <strong>➡️ <code>ExceptionHandler</code> is a <a href="https://medium.com/ruby-on-rails-web-application-development/custom-400-500-error-pages-in-ruby-on-rails-exception-handler-3a04975e4677"><code>Custom Error Pages Gem</code></a> For Ruby on Rails ⬅️</strong> - With <strong>160,000+ downloads</strong>, it is one of the most <br /> <strong>popular</strong>, <strong>robust</strong> & <strong>extensible</strong> exceptions management gems for <strong><a href="https://rubygems.org/gems/exception_handler">Ruby on Rails 4 & 5+</a></strong>...
18
- </p>
3
+ <!-- Intro -->
4
+ <div id="intro">
5
+ <h4 align="center"><code><strong><a href="https://www.github.com/richpeck/exception_handler">ExceptionHandler</a></strong></code> is presently the MOST POPULAR exceptions gem for <a href="https://medium.com/ruby-on-rails-web-application-development/custom-400-500-error-pages-in-ruby-on-rails-exception-handler-3a04975e4677">CUSTOM Rails error pages</a>.</h4>
6
+ <p align="center">
7
+ With <strong>290,000+ downloads</strong>, it is the *only* gem to provide <strong>custom 400/500 exception pages for Rails 5 & 6</strong>
8
+ </p>
9
+ <p><img src="./readme/dev.png" /></p>
10
+ <h4 align="center">Current <a href="https://github.com/richpeck/exception_handler/releases"><u>0.8.0.0</u></a> (August 2018)</h4>
11
+ </div>
19
12
 
13
+ <!-- Badges -->
20
14
  <p align="center">
21
15
  <a href="http://badge.fury.io/rb/exception_handler"><img src="https://badge.fury.io/rb/exception_handler.svg" align="absmiddle"></a>
22
16
  <a href="http://rubygems.org/gems/exception_handler"><img src="http://ruby-gem-downloads-badge.herokuapp.com/exception_handler/0.5.1?type=total&color=brightgreen" align="absmiddle" /></a>
23
17
  <a href="https://codeclimate.com/github/richpeck/exception_handler"><img src="https://codeclimate.com/github/richpeck/exception_handler/badges/gpa.svg" align="absmiddle"/></a>
24
- <a href="https://gemnasium.com/richpeck/exception_handler"><img src="https://gemnasium.com/richpeck/exception_handler.svg" align="absmiddle"></a>
25
18
  <a href='https://coveralls.io/github/richpeck/exception_handler?branch=master'><img src='https://coveralls.io/repos/github/richpeck/exception_handler/badge.svg?branch=master' alt='Coverage Status' align="absmiddle" /></a>
26
19
  <a href="https://travis-ci.org/richpeck/exception_handler"><img src="https://travis-ci.org/richpeck/exception_handler.svg?branch=master" align="absmiddle"></a>
27
20
  </p>
28
21
 
29
- <p align="center">
30
- <img src="readme/branded/1.jpg" width="425" title="Fully Branded Error Pages" />
31
- <img src="readme/branded/2.jpg" width="425" title="Fully Branded Error Pages" />
32
- </p>
33
-
34
- <p align="center">
35
- <b>Version <a href="https://github.com/richpeck/exception_handler/releases/tag/v0.8.0.0">🏹 <code>0.8.0.0</code> 🏹</a> has now introduced a number of <b>⭐️ KEY UPGRADES ⭐️</b> including...</b> <br /> 🚧 <strong><A href="#config">New Config Settings</a></strong> 🚧 ▪️ <strong>💻 <strong><A href="#views">Custom Views Options</a></strong> 💻</strong> ▪️ <strong>💬 <a href="#locales"><code>4xx</code>/<code>5xx</code> Locales</a> 💬</strong>...
36
- </p>
37
-
38
- <p align="center">
39
- <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" />
40
- <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" />
41
- </p>
42
-
43
- <p align="center">
44
- <strong>
45
- ⚠️ Tutorial shows how it works ⚠️
46
- <br /><a href="mailto: rpeck@frontlineutilities.co.uk" title="rpeck@fl.co.uk">✉️ Support Email ✉️</a>
47
- </strong>
48
- </p>
49
-
50
22
  <!-- Navigation -->
51
23
  <div id="navigation">
52
24
  <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
53
25
  <p align="center">
54
- <b>⌚️ <a href="#introduction">Introduction</a> ⌚️</b> ❙ <strong>✔️ <a href="#installation">Installation</a> ✔️</strong> ❙ <strong>🔨 <a href="#setup">Setup</a> 🔨</strong> ❙ <strong>☎️ <a href="#support">Support</a> ☎️</strong> ❙ <strong>⭐ <a href="#changelog">Changelog</a> ⭐</strong>
26
+ <strong>
27
+ 📝 <a href="#introduction">Introduction</a> -
28
+ ⚠️ <a href="#installation">Installation</a> -
29
+ 🔧 <a href="#configuration">Configuration</a> -
30
+ ☎️ <a href="#support">Support</a> -
31
+ ⭐ <a href="#changelog">Changelog</a>
32
+ </strong>
55
33
  </p>
56
34
  <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
57
35
  </div>
58
36
 
59
- <!-- Version -->
60
- <p align="center">
61
- <img src="./readme/version.jpg" />
62
- </p>
63
-
64
- <p align="center">
65
- <img src="readme/check.png" height="22" title="Fully Responsive" align="absmiddle" />&nbsp; <strong>Responsive</strong> &nbsp;
66
- <img src="readme/check.png" height="22" title="Branded Error Pages" align="absmiddle" />&nbsp; <strong>Branded Error Pages</strong> &nbsp;
67
- <img src="readme/check.png" height="22" title="Middleware Exception Handling" align="absmiddle" />&nbsp; <strong>Middleware Exception Handling</strong> &nbsp;
68
- <img src="readme/check.png" height="22" title="Keep Users Informed" align="absmiddle" />&nbsp; <strong>Fully Customizable</strong> &nbsp;
69
- </p>
70
-
71
- <p align="center">
72
- <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" />
73
- <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" />
74
- </p>
75
-
76
37
  <!-- Introduction -->
77
38
  <div id="introduction">
78
- <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
79
- <p>
80
- <h3>⌚️ Introduction ⌚️</h3>
81
- </p>
82
- <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
39
+ <h4>📝 Introduction</h4>
83
40
  </div>
84
41
 
85
- ➡️ [**`ExceptionHandler`**](https://rubygems.org/gems/exception_handler) ⬅️ was designed to replace Rails' error pages ([`400.html`, `422.html`, `500.html`](https://github.com/rails/rails/tree/ef0b05e78fb0b928c7ef48d3c365dc849af50305/railties/lib/rails/generators/rails/app/templates/public)) with dynamic views...
42
+ ---
43
+ <div>
44
+ <p><b><code>ExceptionHandler</b></code> replaces Rails' default error pages with <strong>dynamic views</strong>.</p>
45
+ <p>It does this by injecting <a href="https://guides.rubyonrails.org/configuring.html#rails-general-configuration"><code>config.exceptions_app</code></a> with our controller - allowing us to populate erroneous responses with our own HTML. To understand how this works, you need to appreciate how Rails handles errors:</p>
46
+ <p align="center"><a href="https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/show_exceptions.rb#L44"><img src="readme/show_exceptions.png" width="550"></a></p>
47
+ <p>Rails uses <a href="https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/show_exceptions.rb"><code><strong>ActionDispatch::ShowExceptions</strong></code></a> (above) to generate error responses.</p>
48
+ <p>Because web browsers (Rails is a web framework) can only interpret <a href="https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Response_message">HTTP responses</a>, Ruby/Rails exceptions have to be translated into something a browser can read. This is done by calling the above middleware.</p>
49
+ <p>--</p>
50
+ <p>As highlighted, an HTTP response is built independent of the Rails stack. This includes assigning an HTTP status code and HTML response body. It's the response body which <code><strong>ExceptionHandler</strong></code> is designed to override.</p>
51
+ </div>
86
52
 
53
+ <!-- Sep -->
87
54
  <p align="center">
88
- <img src="./readme/http_codes.png" />
55
+ <img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" />
89
56
  </p>
90
57
 
91
- The gem inserts a custom [ `controller`](app/controllers/exception_handler/exceptions_controller.rb) into [`exceptions_app`](http://guides.rubyonrails.org/configuring.html#rails-general-configuration), allowing us to render custom HTML for erroneous requests.
92
-
93
- The controller uses a *single* method/view to build a response to errors. This view remains the same for *every* exception; the ONLY change is the *[layout](/app/views/layouts/exception.html.erb)* - depending on the HTTP response being returned (`4xx`/`5xx`).
94
-
95
- The beauty lies in the *simplicity* through which this is achieved → rather than having many different elements, its SOLE focus is to provide different HTML responses via differing *layouts*. `ExceptionHandler` does this within the scope of [`ActionView`](http://guides.rubyonrails.org/action_view_overview.html), allowing for the use of `views`, `helpers` and `data` from the database.
96
-
97
- Gem works 100% out of the box in `production`, and has the option to be called in [`dev`](#dev) if necessary.
98
-
99
- --
100
-
101
- ### 📑 HTTP
102
-
103
- The most important thing to understand is that *it doesn't matter* which errors Ruby/Rails raises - they *all* need to be wrapped in a [valid HTTP response](https://www.w3.org/Protocols/rfc2616/rfc2616-sec6.html). Due to the nature of HTTP, you only need to facilitate responses for [`4xx`](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_errors) - [`5xx`](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_errors).
104
-
105
- This means that all you're really doing is taking "Ruby" errors and giving them an appropriate [HTTP status code](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) & [message body](https://en.wikipedia.org/wiki/HTTP_message_body) (HTML). Rails handles the process for you - the *only* thing we need to worry about is how the HTML is generated.
106
-
107
- What confuses most is the way in which Rails does this. The process is handled by [`ActionDispatch::ShowExceptions`](https://github.com/rails/rails/blob/master/actionpack/lib/action_dispatch/middleware/show_exceptions.rb#L44) - which builds a new response out of the one passed to it by the exception generator. Through this process, it calls whichever class is present in [`exceptions_app`](http://guides.rubyonrails.org/configuring.html#rails-general-configuration)...
108
-
109
- # show_exceptions.rb
110
- def render_exception(request, exception)
111
- backtrace_cleaner = request.get_header "action_dispatch.backtrace_cleaner"
112
- wrapper = ExceptionWrapper.new(backtrace_cleaner, exception)
113
- status = wrapper.status_code
114
- request.set_header "action_dispatch.exception", wrapper.exception
115
- request.set_header "action_dispatch.original_path", request.path_info
116
- request.path_info = "/#{status}"
117
- response = @exceptions_app.call(request.env) #-> this is where the HTML is generated
118
- response[1]["X-Cascade"] == "pass" ? pass_response(status) : response
119
- rescue Exception => failsafe_error
120
- $stderr.puts "Error during failsafe response: #{failsafe_error}\n #{failsafe_error.backtrace * "\n "}"
121
- FAILSAFE_RESPONSE
122
- end
123
-
124
- In other words, what a user *sees* has very little to do with the fact Rails experienced an error. `ExceptionHandler` doesn't change this behaviour - it simply adds our own controller/views setup to provide the HTML...
125
-
126
- <p align="center">
127
- <img src="./readme/middleware.jpg" />
128
- </p>
58
+ <!-- Installation -->
59
+ <div id="installation">
60
+ <h4>⚠️ Installation</h4>
61
+ </div>
129
62
 
130
- To better explain, there are **<a href="https://tzamtzis.gr/2017/digital-analytics/http-status-codes/">5️⃣ types of HTTP status code</a>** - [`10x`][10x], [`20x`][20x], [`30x`][30x], [`40x`][40x], & [`50x`][50x].
63
+ ---
131
64
 
132
- Each does its own thing, but what's important is they *ALL* describe "responses" that your web browser will receive for HTTP requests. The only *erroneous* status codes are `4xx` (client error) or `5xx` (server error)...
65
+ <div>
66
+ <p>
67
+ 💎 <u><a href="https://rubygems.org/gems/exception_handler">RubyGems</a></u> (Code) |
68
+ 💻 <u><a href="https://medium.com/ruby-on-rails-web-application-development/custom-400-500-error-pages-in-ruby-on-rails-exception-handler-3a04975e4677">Medium</a></u> (Tutorial)
69
+ </p>
70
+ <pre><code># Gemfile
71
+ gem 'exception_handler', '~> 0.8.0.0'</code></pre>
72
+ <p>Because <b>ExceptionHandler</b> is built around a Rails engine, there is <b>nothing</b> to be done to get it working in production. Installing the Gem <b><i>should</i></b> translate your production 4xx/5xx error pages into dynamic views.</p>
73
+ <p>Environments <u>other</u> than production (development/staging) required the <a href="#dev"><code>dev</code></a> variable to be <code>true</code>.</p>
74
+ </div>
133
75
 
76
+ <!-- Sep -->
134
77
  <p align="center">
135
- <img src="./readme/HTTP.png" />
78
+ <img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" />
136
79
  </p>
137
80
 
138
- The point is that when you're dealing with "errors" online, you're *actually* dealing with erroneous **HTTP STATUS CODES**. The response delivered with these codes is *ALWAYS* going to remain the same; difference lying in how they're built (on the server).
139
-
140
- By default, `NGinx` + `Apache` use "static" HTML pages to show the errors - if we're using Rails, we have the ability to create *our own* pages. This is exactly what our gem has been designed to do.
141
-
142
- **`ExceptionHandler`** provides Rails with the ability to serve ***dynamic*** exception pages, built with **your *own*** layouts/views. By overriding the <a href="http://guides.rubyonrails.org/configuring.html#rails-general-configuration">`exceptions_app`</a> hook, it provides a custom `controller`, `model` and `views` to display custom error pages.
81
+ <!-- configuration -->
82
+ <div id="configuration">
83
+ <h4>🔧 Configuration</h4>
84
+ </div>
143
85
 
144
- The system is 100% compatible with Rails 4 & 5 and has already been downloaded **180,000+** times...
86
+ ---
145
87
 
146
88
  <p align="center">
147
- <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" />
148
- <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" />
89
+ <g-emoji class="g-emoji" alias="file_folder" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4c1.png">📁</g-emoji> <a href="#config">Config</a>&nbsp;&nbsp;&nbsp;&nbsp;<g-emoji class="g-emoji" alias="computer" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4bb.png">💻</g-emoji> <a href="#dev" title="Dev Mode">Dev</a>&nbsp;&nbsp;&nbsp;&nbsp;<g-emoji class="g-emoji" alias="floppy_disk" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4be.png">💾</g-emoji> <a href="#db">Database</a>&nbsp;&nbsp;&nbsp;&nbsp;<g-emoji class="g-emoji" alias="email" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/2709.png">✉️</g-emoji> <a href="#email">Email</a>&nbsp;&nbsp;&nbsp;&nbsp;<g-emoji class="g-emoji" alias="eyeglasses" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f453.png">👓</g-emoji> <a href="#views">Views</a>&nbsp;&nbsp;&nbsp;&nbsp;<g-emoji class="g-emoji" alias="speech_balloon" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4ac.png">💬</g-emoji> <a href="#locales">Locales</a>&nbsp;&nbsp;&nbsp;&nbsp;<g-emoji class="g-emoji" alias="clipboard" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/1f4cb.png">📋</g-emoji> <a href="#layouts">Layouts</a>&nbsp;&nbsp;&nbsp;&nbsp;<g-emoji class="g-emoji" alias="no_entry" fallback-src="https://github.githubassets.com/images/icons/emoji/unicode/26d4.png">⛔️</g-emoji> <a href="#custom-exceptions">Custom Exceptions</a>
149
90
  </p>
150
91
 
151
- <!-- Setup -->
152
- <div id="setup">
153
- <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
154
- <h3 align="center">🔨 Setup 🔨</h3>
155
- <p align="center">-- <br />The <i>most</i> important thing to appreciate about the gem is that it's designed to be <b><em>completely</em> unobtrusive</b>.</p>
156
- <p align="center">This means that if you're looking at using it, </p>
157
- <p align="center"><img src="./readme/dev.png" /></p>
158
- <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
159
- <p align="center">
160
- <a href="#config"><img src="readme/titles/icons/config.png" alt="Configuration Options" align="absmiddle" height="24" /> Config</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#dev" title="Dev Mode"><img src="readme/titles/icons/dev.png" alt="Dev" align="absmiddle" height="24" /> Dev</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#database"><img src="readme/titles/icons/database.png" alt="Database" align="absmiddle" height="24" /> Database</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#email"><img src="readme/titles/icons/email.png" alt="Email" align="absmiddle" height="24" /> Email</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#views"><img src="readme/titles/icons/views.png" alt="Views" align="absmiddle" height="24" /> Views</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#locales"><img src="readme/titles/icons/locales.png" alt="Locales" align="absmiddle" height="20" /> Locales</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#custom-exceptions"><img src="readme/titles/icons/custom.png" alt="Custom Exceptions" align="absmiddle" height="18" /> Custom Exceptions</a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="#generators"><img src="readme/titles/icons/generators.png" alt="Generators" align="absmiddle" height="24" /> Generators</a>
161
- </p>
162
- <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
163
- </div>
92
+ ---
164
93
 
165
94
  <!-- Config -->
166
- <p id="config">
167
- <h4>🚧 Config 🚧</h4>
168
- </p>
95
+ <a name="config"></a>
169
96
 
170
- **The ONLY thing you need to configure `ExceptionHandler` is the [`config`](https://github.com/richpeck/exception_handler/blob/master/lib/exception_handler/config.rb)**.
97
+ The **ONLY** thing you need to manage `ExceptionHandler` is its [`config`](https://github.com/richpeck/exception_handler/blob/master/lib/exception_handler/config.rb) settings.
171
98
 
172
- Whilst the gem **works out of the box** (without any configuration), if you want to manage the [`layouts`](#layouts), [`email`](#email), [`dev`](#dev) or the [`database`](#db), you'll need to set the appropriate values in the config hash ([invoked at init](https://github.com/richpeck/exception_handler/blob/master/lib/exception_handler/engine.rb#L44)).
99
+ Whilst the gem **works out of the box** (without any configuration), if you want to manage the [`layouts`](#layouts), [`email`](#email), [`dev`](#dev) or the [`database`](#db), you'll need to set the appropriate values in the config hash.
173
100
 
174
- This can be done in `config/application.rb` or `config/environments/[env].rb` ↴
101
+ This is done in `config/application.rb` or `config/environments/[env].rb` ↴
175
102
 
176
- ```
103
+ ```rb
177
104
  # config/application.rb
178
105
 
179
106
  module YourApp
@@ -189,6 +116,11 @@ module YourApp
189
116
  db: nil, # allocates a "table name" into which exceptions are saved (defaults to nil)
190
117
  email: nil, # sends exception emails to a listed email (string // "you@email.com")
191
118
 
119
+ # Custom Exceptions
120
+ custom_exceptions: {
121
+ #'ActionController::RoutingError' => :not_found # => example
122
+ },
123
+
192
124
  # On default 5xx error page, social media links included
193
125
  social: {
194
126
  facebook: nil, # Facebook page name
@@ -238,7 +170,6 @@ module YourApp
238
170
 
239
171
  }
240
172
  }
241
-
242
173
  end
243
174
  end
244
175
  ```
@@ -247,31 +178,36 @@ For a full retinue of the available options, you'll be best looking at the [`con
247
178
 
248
179
  --
249
180
 
250
- If using an [`engine`](http://guides.rubyonrails.org/engines.html), **DON'T need an `initializer`**:
251
-
252
- # lib/engine.rb
253
- module YourModule
254
- class Engine < Rails::Engine
181
+ If using an [`engine`](http://guides.rubyonrails.org/engines.html), you **DON'T need an `initializer`**:
182
+ ```rb
183
+ # lib/engine.rb
184
+ module YourModule
185
+ class Engine < Rails::Engine
255
186
 
256
- # => ExceptionHandler
257
- # => Works in and out of an initializer
258
- config.exception_handler = {
259
- dev: nil, # => this will not load the gem in development
260
- db: true # => this will use the :errors table to store exceptions
261
- }
262
- end
187
+ # => ExceptionHandler
188
+ # => Works in and out of an initializer
189
+ config.exception_handler = {
190
+ dev: nil, # => this will not load the gem in development
191
+ db: true # => this will use the :errors table to store exceptions
192
+ }
193
+ end
194
+ end
195
+ ```
263
196
 
264
- end
197
+ The best thing about using a `config` options block is that you are able to only define the options that you require.
265
198
 
266
- The best thing about using a `config` options block is that you are able to only define the options that you require. This means that if you have particular options you *only* wish to run in `staging`, or have single options for `production` etc...
199
+ If you have particular options you *only* wish to run in `staging`, or have single options for `production` etc, this setup gives you the ability to manage it properly...
267
200
 
268
201
  ---
269
202
 
270
- <p id="dev">
271
- <h4>💻 Dev 💻</h4>
272
- </p>
203
+ <!-- Dev -->
204
+ <div id="dev">
205
+ <h5>💻 Dev</h5>
206
+ </div>
207
+
208
+ As explained, `ExceptionHandler` does *not* work in `development` by default.
273
209
 
274
- As explained, `ExceptionHandler` does not work in `development` mode by default. This is because it overrides the `exceptions_app` middleware hook - which is only invoked in `production` or `staging`...
210
+ This is because it overrides the `exceptions_app` middleware hook - which is *only* invoked in `production` or `staging`.
275
211
 
276
212
  <p align="center">
277
213
  <img src="./readme/dev.png" />
@@ -285,26 +221,33 @@ To get it working in `development`, you need to override the [`config.consider_a
285
221
 
286
222
  This is normally done by changing the setting in your Rails config files. However, to make the process simpler for `ExceptionHandler`- we've added a `dev` option which allows you to override the hook through the context of the gem...
287
223
 
288
- ```
224
+ ```rb
289
225
  # config/application.rb
290
226
  config.exception_handler = { dev: true }
291
227
  ```
292
228
 
293
- This disables [`config.consider_all_requests_local`](http://guides.rubyonrails.org/configuring.html#rails-general-configuration), making Rails behave as it would in production:
229
+ This disables [`config.consider_all_requests_local`](http://guides.rubyonrails.org/configuring.html#rails-general-configuration), making Rails behave as it would in production.
294
230
 
295
- ![Dev][dev_img]
231
+ Whilst simple, it's not recommended for extended use. Very good for testing new ideas etc.
296
232
 
297
- Obviously, this has other connotations including the likes of making your requests go through your production server etc. For this reason, it's *STRONGLY* recommended you only use the `dev` option to test your layouts etc.
233
+ ---
298
234
 
299
- ----
235
+ <!-- DB -->
236
+ <div id="db">
237
+ <h5>💾 DB</h5>
238
+ </div>
300
239
 
301
- <p id="database">
302
- <h4>💾 Database 💾</h4>
303
- </p>
240
+ To save exceptions to your database, you're able to set the `db` option.
304
241
 
305
- If you want to save exceptions to your database, you will need to migrate a new
242
+ Because we use a `controller` to manage the underlying way the system works, we're able to invoke the likes of a [`model`](https://github.com/richpeck/exception_handler/blob/master/app/models/exception_handler/exception.rb) with other functionality.
306
243
 
307
- ```
244
+ Ths is done automatically with the latest version of `ExceptionHandler`.
245
+
246
+ To do this, once you've populated the option with either `true` or a `string`, run `rails db:migrate` from your console.
247
+
248
+ Our new [`migration system`](https://github.com/richpeck/exception_handler/tree/readme#migrations) will automatically run the migration.
249
+
250
+ ```rb
308
251
  # config/application.rb
309
252
  config.exception_handler = { db: true }
310
253
  ```
@@ -313,124 +256,213 @@ This enables `ActiveRecord::Base` on the [`Exception`](app/models/exception_hand
313
256
 
314
257
  In order for this to work, your db needs the correct table.
315
258
 
316
- To do this, once you've enabled the option, run `rails db:migrate` from your console. Our new [`migration system`](https://github.com/richpeck/exception_handler/tree/readme#migrations) will automatically run the migration.
317
-
318
259
  ---
319
260
 
320
- <p id="email">
321
- <h4>✉️ Email ✉️</h4>
322
- </p>
261
+ <!-- Email -->
262
+ <div id="email">
263
+ <h5>✉️ Email</h5>
264
+ </div>
323
265
 
324
- **`ExceptionHandler` also now sends email notifications.**
266
+ `ExceptionHandler` also sends **email notifications**.
325
267
 
326
268
  If you want to receive emails whenever your application raises an error, you can do so by adding your email to the config:
327
269
 
328
- # config/application.rb
329
- config.exception_handler = {
330
- email: "your@email.com"
331
- }
270
+ ```rb
271
+ # config/application.rb
272
+ config.exception_handler = {
273
+ email: "your@email.com"
274
+ }
275
+ ```
332
276
 
333
277
  > **Please Note** this requires [`ActionMailer`](http://guides.rubyonrails.org/action_mailer_basics.html). If you don't have any outbound SMTP server, [`SendGrid`](http://sendgrid.com) is free.
334
278
 
335
- [Full tutorial here](https://github.com/richpeck/exception_handler/wiki/2-Email)
279
+ From version [`0.8.0.0`](https://github.com/richpeck/exception_handler/releases/tag/v0.8.0.0), you're able to define whether email notifications are sent on a per-error basis:
336
280
 
281
+ ```rb
282
+ # config/application.rb
283
+ config.exception_handlder = {
284
+
285
+ # This has to be present for any "notification" declarations to work
286
+ # Defaults to 'false'
287
+ email: "test@test.com",
288
+
289
+ # Each status code in the new "exceptions" block allows us to define whether email notifications are sent
290
+ exceptions: {
291
+ :all => { notification: true },
292
+ :50x => { notification: false },
293
+ 500 => { notification: false }
294
+ }
295
+ }
296
+ ```
337
297
  ---
338
298
 
339
- <p id="views">
340
- <h4>👓 Views 👓</h4>
341
- </p>
299
+ <!-- Views -->
300
+ <div id="views">
301
+ <h5>👓 Views</h5>
302
+ </div>
303
+
304
+ What *most* people want out of the view is to change the way it ***looks***. This can be done without changing the "view" itself.
342
305
 
343
- The **views** system in `ExceptionHandler` is modular.
306
+ To better explain, if [`ExceptionsController`](https://github.com/richpeck/exception_handler/blob/master/app/controllers/exception_handler/exceptions_controller.rb) is invoked (by `exceptions_app`), it has **ONE** method ([`show`](https://github.com/richpeck/exception_handler/blob/master/app/controllers/exception_handler/exceptions_controller.rb#L42)).
344
307
 
345
- What *most* people want out of the view is to change the way it ***looks***. This can be done without changing the exception "view" itself...
308
+ This method calls the [`show` view](https://github.com/richpeck/exception_handler/blob/master/app/views/exception_handler/exceptions/show.html.erb), which is *entirely* dependent on the locales for content & the layout for the look.
309
+
310
+ This means that if you wish to change how the view "looks" - you're *either* going to want to change your [layout][layouts] or the [*locales*](#locales). There is NO reason to change the `show` view itself - it's succinct and entirely modular. Whilst you're definitely at liberty to change it, you'll just be making the issue more complicated than it needs to be.
311
+
312
+ --
313
+
314
+ We've also included a number of routes which shows in [`dev`](dev) mode (allowing you to test):
346
315
 
347
316
  <p align="center">
348
- <img src="./readme/dev.png" />
317
+ <img src="./readme/routes.jpg" />
349
318
  </p>
350
319
 
351
- To better explain, if [`ExceptionsController`](https://github.com/richpeck/exception_handler/blob/0.8/app/controllers/exception_handler/exceptions_controller.rb) is invoked (by `exceptions_app`), it has **ONE** method ([`show`](https://github.com/richpeck/exception_handler/blob/0.8/app/controllers/exception_handler/exceptions_controller.rb#L42)). This method calls the [`show` view](https://github.com/richpeck/exception_handler/blob/0.8/app/views/exception_handler/exceptions/show.html.erb), which is *entirely* dependent on the locales for content & the layout for the look.
320
+ ---
352
321
 
353
- This means that if you wish to change how the view "looks" - you're *either* going to want to change your *layouts* or the [*locales*](#locales). There is NO reason to change the `show` view itself - it's succinct and entirely modular. Whilst you're definitely at liberty to change it, you'll just be making the issue more complicated than it needs to be.
322
+ <!-- Locales -->
323
+ <div id="locales">
324
+ <h5>💬 Locales</h5>
325
+ </div>
354
326
 
355
- -
327
+ [Locales](https://github.com/richpeck/exception_handler/blob/Readme/config/locales/exception_handler.en.yml) are used to create interchangeable text (translations/internationalization).
356
328
 
357
- If you wish to change the "layout" / "look", there are **two** options...
329
+ --
358
330
 
359
- * Firstly, you can create your own layout. This is done by changing the
331
+ In `ExceptionHandler`, it provides the wording for each type of error code.
360
332
 
361
- * Secondly,
333
+ By default, the English name of the error is used (`"404"` will appear as `"Not Found"`) - if you want to create custom messages, you're able to do so by referencing the error's ["status_code"](https://github.com/rack/rack/blob/master/lib/rack/utils.rb#L492) within your locales file:
362
334
 
363
- ---
335
+ ```yml
336
+ # config/locales/en.yml
337
+ en:
338
+ exception_handler:
339
+ not_found: "Your message here" # -> 404 page
340
+ unauthorized: "You need to login to continue"
341
+ internal_server_error: "This is a test to show the %{status} of the error"
342
+ ```
364
343
 
365
- <p id="locales">
366
- <h4>💬 Locales 💬</h4>
367
- </p>
344
+ You get access to [`%{message}` and `%{status}`](https://github.com/richpeck/exception_handler/blob/master/app/views/exception_handler/exceptions/show.html.erb#L1), both inferring from an [`@exception`](https://github.com/richpeck/exception_handler/blob/master/app/controllers/exception_handler/exceptions_controller.rb#L20) object we invoke in the controller...
368
345
 
369
- Locales are used to denote interchangeable text (for different languages).
346
+ - `%{message}` is the error's actual message ("XYZ file could not be shown")
347
+ - `%{status}` is the error's status code ("Internal Server Error")
370
348
 
371
- We've used it for a different purpose - to provide text for our "show" view. The beauty of this is that 1) It's entirely modular & 2) It's extensible (we are able to use as many locales as required)...
349
+ --
372
350
 
373
- [[ locales ]]
351
+ By default, only `internal_server_error` is customized by the gem:
374
352
 
353
+ ```yml
354
+ # config/locales/en.yml
355
+ en:
356
+ exception_handler:
357
+ internal_server_error: "<strong>%{status} Error</strong> %{message}"
358
+ ```
359
+ ---
360
+
361
+ <!-- Layouts -->
362
+ <div id="layouts">
363
+ <h5>📋 Layouts</h5>
364
+ </div>
375
365
 
376
- The `ExceptionHandler` view is populated by [`@exception.description`](app/models/exception_handler/exception.rb#L121), which pulls from the `locales`.
366
+ The most attractive feature of `ExceptionHandler` (for most) is its ability to manage [`layouts`](https://guides.rubyonrails.org/layouts_and_rendering.html#structuring-layouts) for HTTP status.
377
367
 
378
- If you want custom messages, you need the following. The key is defined by the HTTP [`status_code`](https://github.com/rack/rack/blob/1.5.2/lib/rack/utils.rb#L544)
368
+ --
379
369
 
380
- # config/locales/en.yml
381
- en:
382
- exception_handler:
383
- not_found: "Your message here"
384
- unauthorized: "You need to login to continue"
385
- internal_server_error: "This is a test to show the %{status} of the error"
370
+ The reason for this is due to the way in which Rails works → the "layout" is a "wrapper" for the returned HTML (the "styling" of a page). If you have no layout, it will render the "view" HTML and nothing else.
386
371
 
387
- You get access to `%{message}` and `%{status}`, both inferring from `@exception`.
372
+ This means if you want to change the "look" of a Rails action, you simply have to be able to change the `layout`. You should not change the view at all.
388
373
 
389
- ---
374
+ To this end, `ExceptionHandler` has been designed around providing a [SINGLE VIEW](app/controllers/exception_handler/exceptions_controller.rb#L44) for exceptions. This view does not need to change (although you're welcome to use a [`generator`][generators] to do so) - the key is the `layout` that's assigned...
390
375
 
391
- <p id="layouts">
392
- <h4>📋 Layouts 📋</h4>
393
- </p>
376
+ - [`4xx`](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_errors) errors are given a `nil` layout (by default) (inherits from `ApplicationController` in your main app)
377
+ - [`5xx`](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_errors) errors are assigned our own [`exception`](app/views/layouts/exception.html.erb) layout:
378
+
379
+ ```rb
380
+ # config/application.rb
381
+ config.exception_handler = {
382
+
383
+ # The new syntax allows us to assign different values to each HTTP status code
384
+ # At the moment, only 'layout' & 'notification' are supported
385
+ # We plan to include several more in the future...
386
+
387
+ exceptions: {
388
+ all: { layout: nil } # -> this will inherit from ApplicationController's layout
389
+ }
390
+ }
391
+ ```
394
392
 
395
- ![Layout][layout_img]
393
+ The `layout` system has changed between [`0.7.7.0`](releases/tag/v0.7.7.0) and [`0.8.0.0`](releases/tag/v0.8.0.0).
396
394
 
397
- If you want to change the various layouts, you need to use the [`config`](#config) to set them.
395
+ Building on the former's adoption of HTTP status-centric layouts, it is now the case that we have the `all`, `5xx` and `4xx` options - allowing us to manage the layouts for blocks of HTTP errors respectively:
398
396
 
399
- ![Layout][layouts_img]
397
+ ```rb
398
+ # config/application.rb
399
+ config.exception_handler = {
400
+
401
+ # Old (still works)
402
+ # No "all" / "4xx"/"5xx" options
403
+ layouts: {
404
+ 500 => 'exception',
405
+ 501 => 'exception'
406
+ },
407
+
408
+ # New
409
+ exceptions: {
410
+ :all => { layout: 'exception' },
411
+ :4xx => { layout: 'exception' },
412
+ :5xx => { layout: 'exception' }, # -> this overrides the :all declaration
413
+ 500 => { layout: nil } # -> this overrides the 5xx declaration
414
+ }
415
+ }
416
+ ```
400
417
 
401
- By default, `5xx` errors are shown with our [`exception` layout][layout] - this can be overridden by changing the `config` to use a layout of your choice. If you want to inherit the `ApplicationController` layout, assign the codes to `nil`.
418
+ We've bundled the [`exception`](app/views/layouts/exception.html.erb) layout for `5xx` errors because since these denote internal server errors, it's best to isolate the view system as much as possible. Whilst you're at liberty to change it, we've found it sufficient for most use-cases.
402
419
 
403
420
  ---
404
421
 
422
+ <!-- Custom Exceptions -->
423
+ <div id="custom-exceptions">
424
+ <h5>⛔️ Custom Exceptions</h5>
425
+ </div>
405
426
 
406
- <p id="custom-exceptions">
407
- <h4>⛔️ Custom Exceptions ⛔️</h4>
408
- </p>
427
+ As mentioned, Rails' primary role is to convert Ruby exceptions into HTTP errors.
409
428
 
410
- **Custom Exceptions also supported in [`0.7.5`](https://github.com/richpeck/exception_handler/releases/tag/0.7.5)**
429
+ Part of this process involves mapping Ruby/Rails exceptions to the equivalent HTTP status code.
411
430
 
412
- Rails handles this for us - [**`config.action_dispatch.rescue_responses`**][rescue_responses] ↴
431
+ This is done with [`config.action_dispatch.rescue_responses`](https://github.com/rack/rack/blob/master/lib/rack/utils.rb#L492).
413
432
 
414
- ![ActionDispatch][config.action_dispatch.rescue_responses]
433
+ <p align="center">
434
+ <img src="./readme/custom_exceptions.png" />
435
+ </p>
415
436
 
416
- You need to add to the `rescue_responses` hash in your app's config (mapped to [`status codes`](https://github.com/rack/rack/blob/1.5.2/lib/rack/utils.rb#L544)):
437
+ Whilst this works well, it may be the case that you want to map your own classes to an HTTP status code (default is `Internal Server Error`).
417
438
 
418
- # config/application.rb
419
- config.action_dispatch.rescue_responses["ActionController::YourError"] = :bad_request
439
+ If you wanted to keep this functionality inside `ExceptionHandler`, you're able to do it as follows:
420
440
 
421
- Because `HTTP` can only process `4xx` / `5xx` errors, if `Rails` raises an exception, it needs to assign one of the error status codes. **Default** is [`internal_server_error`](https://github.com/rack/rack/blob/1.5.2/lib/rack/utils.rb#L595) - if you'd prefer your app to just return `500` errors for your custom exception, you don't need to explicitly declare them.
441
+ ```rb
442
+ # config/application.rb
443
+ config.exception_handler = {
444
+ custom_exceptions: {
445
+ 'CustomClass::Exception' => :not_found
446
+ }
447
+ }
448
+ ```
422
449
 
423
- ---
450
+ Alternatively, you're able to still do it with the default Rails behaviour:
424
451
 
425
- <p id="generators">
426
- <h4>💼 Generators 💼</h4>
427
- </p>
452
+ ```rb
453
+ # config/application.rb
454
+ config.action_dispatch.rescue_responses = { 'CustomClass::Exception' => :not_found }
455
+ ```
456
+ ---
428
457
 
429
- **You can generate `ExceptionHandler` into your own application.**
458
+ <!-- Generators -->
459
+ <div id="generators">
460
+ <h5>💼 Generators</h5>
461
+ </div>
430
462
 
431
- [[ Generator ]]
463
+ If you want to edit the `controller`, `views`, `model` or `assets`, you're able to invoke them in your own application.
432
464
 
433
- The following commands will copy the directories...
465
+ This is done - as with other gems - with a single [`generator`](https://github.com/richpeck/exception_handler/blob/master/lib/generators/exception_handler/views_generator.rb) which takes a series of arguments:
434
466
 
435
467
  rails g exception_handler:views
436
468
  rails g exception_handler:views -v views
@@ -439,74 +471,68 @@ The following commands will copy the directories...
439
471
  rails g exception_handler:views -v assets
440
472
  rails g exception_handler:views -v views controllers models assets
441
473
 
442
- If you don't include any switches, this will copy **all** the folders put into your app.
474
+ If you don't include any switches, this will copy **all** `ExceptionHandler`'s folders put into your app.
443
475
 
444
476
  Each switch defines which folders you want (EG `-v views` will only copy `views` dir).
445
477
 
446
478
  ---
447
479
 
448
- <p id="migrations">
449
- <h4>✔️ Migrations (deprecated) ✔️</h4>
450
- </p>
480
+ <!-- Migrations -->
481
+ <div id="migrations">
482
+ <h5>✔️ Migrations</h5>
483
+ </div>
451
484
 
452
- **You *DON'T* need to generate a migration any more**.
485
+ You **DON'T** need to generate a migration anymore.
453
486
 
454
487
  From [`0.7.5`](https://github.com/richpeck/exception_handler/releases/tag/0.7.5), the `migration` generator has been removed in favour of our own [migration system](lib/exception_handler/engine.rb#L58).
455
488
 
456
489
  The reason we did this was so not to pollute your migrations folder with a worthless file. Our migration doesn't need to be changed - we only have to get it into the database and the gem takes care of the rest...
457
490
 
458
- > If you set the `db` option in config, run `rails db:migrate` and the migration will be run.
491
+ > If you set the [`db`][db] option in config, run `rails db:migrate` and the migration will be run.
459
492
 
460
493
  To rollback, use the following:
461
494
 
462
495
  rails db:migrate:down VERSION=000000
463
496
 
464
- The drawback to this is that if you remove `ExceptionHandler` before you rollback the migration, it won't exist anymore. You can **only** fire the `rollback` when you have `ExceptionHandler` installed.
497
+ The drawback to this is that if you remove `ExceptionHandler` before you rollback the migration, it won't exist anymore.
465
498
 
466
- <!-- Support -->
467
- <div id="support">
468
- <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
469
- <h3>☎️ Support ☎️</h3>
470
- <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
471
- </div>
499
+ You can **only** fire the `rollback` when you have `ExceptionHandler` installed.
472
500
 
473
- <p align="center"><b>🚨 <em>Obviously</em>, if you've taken the time to use the gem, it makes sense to <a href="https://github.com/richpeck/exception_handler/issues">support</a> it 🚨!</b></p>
501
+ <!-- Sep -->
502
+ <p align="center">
503
+ <img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" />
504
+ </p>
474
505
 
475
- The fastest way to get a **direct response** is via [email](mailto:rpeck@frontlineutilities.co.uk).
506
+ <!-- Support-->
507
+ <div id="support">
508
+ <h4>☎️ Support</h4>
509
+ </div>
476
510
 
477
- You're also welcome to access our [**Issues**](https://github.com/richpeck/exception_handler/issues) page to contact us directly. You could also use [**StackOverflow**](https://stackoverflow.com/questions/tagged/ruby-on-rails+exceptionhandler)...
511
+ ---
478
512
 
479
- - ⚠️ [**Issues**](https://github.com/richpeck/exception_handler/issues) ⚠️
480
- - 🚩 [**StackOverflow**](https://stackoverflow.com/questions/tagged/ruby-on-rails+exceptionhandler) 🚩
481
- - ✉️ [**Email**](mailto:rpeck@frontlineutilities.co.uk) ✉️
482
- - ✏️ [**Medium**](https://medium.com/ruby-on-rails-web-application-development/custom-400-500-error-pages-in-ruby-on-rails-exception-handler-3a04975e4677) ✏️
483
- - 🎥 [**YouTube**](https://www.youtube.com/channel/UC247lm76ECX1aSvVuhXxe6g) 🎥
513
+ <div>
514
+ <p>You're welcome to contact me directly at <u><a href="mailto:rpeck@frontlineutilities.co.uk"></a><a href="mailto:rpeck@frontlineutilities.co.uk" ref="nofollow">rpeck@frontlineutilities.co.uk</a></u>.</p>
515
+ <p>Alternatively, you may wish to post on our <u><a href="https://github.com/richpeck/exception_handler/issues">GitHub Issues</a></u>, or <u><a href="https://stackoverflow.com/questions/tagged/ruby-on-rails+exceptionhandler" rel="nofollow">StackOverflow</a></u>.</p>
516
+ <p>--</p>
517
+ <p><a href="https://medium.com/ruby-on-rails-web-application-development/custom-400-500-error-pages-in-ruby-on-rails-exception-handler-3a04975e4677" rel="nofollow"><img src="readme/medium.png" target="_blank" alt="Medium" style="max-width:100%;"></a></p>
518
+ </div>
484
519
 
520
+ <!-- Sep -->
485
521
  <p align="center">
486
- <a href="https://www.youtube.com/channel/UC247lm76ECX1aSvVuhXxe6g"><img src="./readme/youtube.png" /></a>
522
+ <img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" />
487
523
  </p>
488
524
 
489
525
  <!-- Changelog -->
490
526
  <div id="changelog">
491
- <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
492
- <h3>⭐ Changelog ⭐</h3>
493
- <p align="center"><img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" /></p>
527
+ <h4>⭐ Changelog</h4>
494
528
  </div>
495
529
 
496
- The most important thing to appreciate is...
497
-
498
- <p align="center"><b>➡️ <code><a href="https://www.rubygems.org/gems/exception_handler">ExceptionHandler</a></code> is designed to provide <strong><A href="https://medium.com/ruby-on-rails-web-application-development/custom-400-500-error-pages-in-ruby-on-rails-exception-handler-3a04975e4677">custom error pages</a></strong> for Ruby on Rails. ⬅️</b></p>
499
-
500
- <p>If you're looking at adding <em><b>extra</b></em> functionality (such as a debugger), you'll probably be better looking at the likes of <code><a href="https://rubygems.org/gems/better_errors">better_errors</a></code> or <code><a href="https://rubygems.org/gems/gaffe">gaffe</a></code>. Whilst we'll certainly look at adding - or integrating - other features (if they're requested), our core intention has always been to provide an exception handling stack that was both simple and customizable.</p>
501
-
502
- --
503
-
504
- What we've built so far...
530
+ ---
505
531
 
506
- ### 👻 [1.0.0.0](https://github.com/richpeck/exception_handler/releases/tag/v1.0.0.0)
532
+ [**1.0.0.0**](https://github.com/richpeck/exception_handler/releases/tag/v1.0.0.0)
507
533
  - [ ] TBA
508
534
 
509
- ### 🏹 [0.8.0.0](https://github.com/richpeck/exception_handler/releases/tag/v0.8.0.0)
535
+ [**0.8.0.0**](https://github.com/richpeck/exception_handler/releases/tag/v0.8.0.0)
510
536
  - [x] [README](https://github.com/richpeck/exception_handler/issues/52) (focus on utility)
511
537
  - [x] Introduction of `4xx`,`5xx`,`:all` for layouts config
512
538
  - [x] Changed `layouts` to `exceptions` in config
@@ -514,20 +540,19 @@ What we've built so far...
514
540
  - [x] Streamlined migration
515
541
  - [x] Updated model
516
542
 
517
- ### 👽 [0.7.7.0](https://github.com/richpeck/exception_handler/releases/tag/v0.7.7.0)
543
+ [**0.7.7.0**](https://github.com/richpeck/exception_handler/releases/tag/v0.7.7.0)
518
544
  - [x] [HTTP status layouts](#layouts)
519
545
 
520
- ### ⚡ 0.7.0.0
546
+ **0.7.0.0**
521
547
  - [x] Wildcard mime types
522
548
  - [x] [Custom exceptions](#custom_exceptions)
523
549
  - [x] Test suite integration
524
- - [x] [Email](#email)
525
550
  - [x] [Model backend](#database)
526
551
  - [x] Sprockets 4+
527
552
  - [x] New layout
528
553
  - [x] Readme / wiki overhaul
529
554
 
530
- ### Ⓜ️ 0.6.5.0
555
+ **0.6.5.0**
531
556
  - [x] Streamlined interface
532
557
  - [x] ActiveRecord / Middleware overhaul
533
558
  - [x] Supports Sprockets 4+ ([`manifest.js`](http://eileencodes.com/posts/the-sprockets-4-manifest/))
@@ -535,7 +560,7 @@ What we've built so far...
535
560
  - [x] Asset overhaul & improvement
536
561
  - [x] Removed dependencies
537
562
 
538
- ### ✔️ 0.5.0.0
563
+ **0.5.0.0**
539
564
  - [x] Locales
540
565
  - [x] Email notifications
541
566
  - [x] Full test suite
@@ -546,42 +571,41 @@ What we've built so far...
546
571
  - [x] Rails asset management improvement
547
572
  - [x] Reduced gem file size
548
573
 
549
- ### ⭕ 0.4.7.0
574
+ **0.4.7.0**
550
575
  - [x] New config system
551
576
  - [x] Fixed controller layout issues
552
577
  - [x] Streamlined middleware
553
578
  - [x] New layout & interface
554
579
 
555
- <!-- Sep -->
556
- <p align="center">
557
- <img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" />
558
- </p>
580
+ <!-- Sep -->
581
+ <p align="center">
582
+ <img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" />
583
+ </p>
559
584
 
560
- [![404 + 500 Errors][banner]][rubygems]
585
+ [![404 + 500 Errors][banner]][rubygems]
561
586
 
562
- <p align="center">
563
- <strong><a href="https://rubygems.org/gems/exception_handler"><code>ExceptionHandler</code></a> is now the • LEADING • custom error pages gem for Rails 4 & 5...</strong>
564
- <br />
565
- No other gem is as simple or effective at providing branded exception pages in production...
566
- </p>
587
+ <p align="center">
588
+ <strong><a href="https://rubygems.org/gems/exception_handler"><code>ExceptionHandler</code></a> provides custom error pages gem for Rails 5+</strong>
589
+ <br />
590
+ No other gem is as simple or effective at providing branded exception pages in production
591
+ </p>
567
592
 
568
- <p align="center">
569
- <a href="http://badge.fury.io/rb/exception_handler"><img src="https://badge.fury.io/rb/exception_handler.svg" align="absmiddle"></a>
570
- <a href="http://rubygems.org/gems/exception_handler"><img src="http://ruby-gem-downloads-badge.herokuapp.com/exception_handler/0.5.1?type=total&color=brightgreen" align="absmiddle" /></a>
571
- <a href="https://codeclimate.com/github/richpeck/exception_handler"><img src="https://codeclimate.com/github/richpeck/exception_handler/badges/gpa.svg" align="absmiddle"/></a>
572
- <a href="https://gemnasium.com/richpeck/exception_handler"><img src="https://gemnasium.com/richpeck/exception_handler.svg" align="absmiddle"></a>
573
- <a href='https://coveralls.io/github/richpeck/exception_handler?branch=master'><img src='https://coveralls.io/repos/github/richpeck/exception_handler/badge.svg?branch=master' alt='Coverage Status' align="absmiddle" /></a>
574
- <a href="https://travis-ci.org/richpeck/exception_handler"><img src="https://travis-ci.org/richpeck/exception_handler.svg?branch=master" align="absmiddle"></a>
575
- </p>
593
+ <p align="center">
594
+ <a href="http://badge.fury.io/rb/exception_handler"><img src="https://badge.fury.io/rb/exception_handler.svg" align="absmiddle"></a>
595
+ <a href="http://rubygems.org/gems/exception_handler"><img src="http://ruby-gem-downloads-badge.herokuapp.com/exception_handler/0.5.1?type=total&color=brightgreen" align="absmiddle" /></a>
596
+ <a href="https://codeclimate.com/github/richpeck/exception_handler"><img src="https://codeclimate.com/github/richpeck/exception_handler/badges/gpa.svg" align="absmiddle"/></a>
597
+ <a href='https://coveralls.io/github/richpeck/exception_handler?branch=master'><img src='https://coveralls.io/repos/github/richpeck/exception_handler/badge.svg?branch=master' alt='Coverage Status' align="absmiddle" /></a>
598
+ <a href="https://travis-ci.org/richpeck/exception_handler"><img src="https://travis-ci.org/richpeck/exception_handler.svg?branch=master" align="absmiddle"></a>
599
+ </p>
576
600
 
577
- <p align="center">
578
- <strong>➡️ <a href="https://rubygems.org/gems/exception_handler">Download & Info</a> ⬅️ </strong>
579
- </p>
601
+ <p align="center">
602
+ <strong>➡️ <a href="https://rubygems.org/gems/exception_handler">Download & Info</a> ⬅️</strong>
603
+ </p>
580
604
 
581
- <!-- Sep -->
582
- <p align="center">
583
- <img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" />
584
- </p>
605
+ <!-- Sep -->
606
+ <p align="center">
607
+ <img src="https://cdn-images-1.medium.com/max/800/1*CKyKxRXLovcrUOB-s8_jCw.png" width="100%" />
608
+ </p>
585
609
 
586
610
  :copyright: <a href="http://www.fl.co.uk" align="absmiddle" ><img src="readme/fl.jpg" height="22" align="absmiddle" /></a> <a href="http://stackoverflow.com/users/1143732/richard-peck?tab=profile" align="absmiddle" ><img src="https://avatars0.githubusercontent.com/u/1104431" height="22" align="absmiddle" /></a> <a href="https://github.com/joehilton" align="absmiddle" ><img src="https://avatars2.githubusercontent.com/u/5063592?s=460&v=4" height="22" align="absmiddle" /></a> <a href="https://github.com/toymachiner62" align="absmiddle" ><img src="https://avatars3.githubusercontent.com/u/485782" height="22" align="absmiddle" /></a> <a href="https://github.com/andrewclink" align="absmiddle" ><img src="https://avatars0.githubusercontent.com/u/688916" height="22" align="absmiddle" /></a> <a href="https://github.com/Startouf" align="absmiddle" ><img src="https://avatars2.githubusercontent.com/u/7388889" height="22" align="absmiddle" /></a> <a href="https://github.com/Tonkonozhenko" align="absmiddle" ><img src="https://avatars0.githubusercontent.com/u/1307646" height="22" align="absmiddle" /></a> <a href="https://github.com/mabako" align="absmiddle" ><img src="https://avatars3.githubusercontent.com/u/125113" height="22" align="absmiddle" /></a> <a href="https://github.com/frankzhao" align="absmiddle" ><img src="https://avatars3.githubusercontent.com/u/555499" height="22" align="absmiddle" /></a>
587
611
 
@@ -594,43 +618,10 @@ What we've built so far...
594
618
  <!-- Images https://github.com/adam-p/markdown-here/wiki/Markdown-Cheatsheet#images -->
595
619
 
596
620
  <!-- Images -->
597
- [dev_mode]: readme/dev_mode.jpg
598
- [dev_img]: readme/dev.png
599
- [layouts_img]: readme/layouts.jpg
600
- [layout_img]: readme/layout.png
601
- [view_img]: readme/view.jpg
602
- [http_codes]: readme/http_codes.png
603
- [config]: readme/config.jpg
604
- [config.action_dispatch.rescue_responses]: readme/config.action_dispatch.rescue_responses.jpg
605
- [banner]: readme/banner.jpg
606
- [gem]: readme/gem.jpg
607
- [gemfile]: readme/gemfile.jpg
608
- [middleware]: readme/middleware.jpg
609
- [exceptions_app]: readme/exceptions_app.jpg
610
- [view]: readme/titles/view.jpg
611
- [dev]: readme/titles/dev.jpg
612
- [db]: readme/titles/db.png
613
- [support]: readme/titles/support.png "Support"
614
- [changelog]: readme/titles/changelog.png "Changelog"
615
- [contribution]: readme/titles/contributions.png "Contributions"
616
- [fl]: readme/fl.jpg "Frontline Utilities LTD"
617
- [profile]: https://avatars0.githubusercontent.com/u/1104431 "R Peck"
621
+ [banner]:readme/banner.jpg
618
622
 
619
623
  <!-- Links -->
620
- [better_errors]: https://github.com/charliesome/better_errors
621
- [layout]: app/views/layouts/exception.html.erb
622
- [status_codes]: http://guides.rubyonrails.org/layouts_and_rendering.html#the-status-option
623
- [stackoverflow]: http://stackoverflow.com/questions/ask?tags=ruby-on-rails+exception-handler
624
- [rescue_responses]: http://guides.rubyonrails.org/configuring.html#configuring-action-dispatch
625
- [latest]: https://github.com/richpeck/exception_handler/releases/latest
626
- [show_exception]: https://github.com/rails/rails/blob/4-0-stable/actionpack/lib/action_dispatch/middleware/show_exceptions.rb
627
- [exception_app]: http://guides.rubyonrails.org/configuring.html#rails-general-configuration
628
624
  [rubygems]: http://rubygems.org/gems/exception_handler
629
- [frontlineutilities.co.uk]: http://www.frontlineutilities.co.uk
630
- [stackoverflow.com]: http://stackoverflow.com/users/1143732/richard-peck?tab=profile
631
- [fork]: #fork-destination-box
632
- [pull]: http://github.com/richpeck/exception_handler/pulls
633
- [issues]: http://github.com/richpeck/exception_handler/issues
634
625
 
635
626
  [10x]: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#1xx_Informational_responses
636
627
  [20x]: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#2xx_Success
@@ -638,5 +629,15 @@ What we've built so far...
638
629
  [40x]: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#4xx_Client_errors
639
630
  [50x]: https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#5xx_Server_errors
640
631
 
632
+ <!-- Local Links -->
633
+ [db]: #db
634
+ [email]: #email
635
+ [dev]: #dev
636
+ [layouts]: #layouts
637
+ [locales]: #locales
638
+ [configuration]: #configuration
639
+ [generators]: #generators
640
+ [custom-exceptions]: #custom-exceptions
641
+
641
642
  <!-- ################################### -->
642
643
  <!-- ################################### -->