exception_handler 0.7.6.0 → 0.7.7.0

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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +40 -33
  3. data/.slugignore +7 -7
  4. data/.travis.yml +5 -5
  5. data/Gemfile +13 -13
  6. data/README.md +436 -436
  7. data/Rakefile +7 -7
  8. data/app/assets/stylesheets/exception_handler.css.erb +18 -18
  9. data/app/assets/stylesheets/styles/_base.css.erb +35 -35
  10. data/app/assets/stylesheets/styles/_exception.css.erb +105 -105
  11. data/app/assets/stylesheets/styles/_footer.css.erb +24 -24
  12. data/app/assets/stylesheets/styles/_responsive.css +5 -5
  13. data/app/controllers/exception_handler/exceptions_controller.rb +59 -59
  14. data/app/mailers/exception_handler/exception_mailer.rb +17 -17
  15. data/app/models/exception_handler/exception.rb +199 -191
  16. data/app/views/exception_handler/exceptions/show.html.erb +3 -3
  17. data/app/views/exception_handler/mailers/layout.haml +8 -8
  18. data/app/views/exception_handler/mailers/layout.text.erb +1 -1
  19. data/app/views/exception_handler/mailers/new_exception.erb +4 -4
  20. data/app/views/layouts/exception.html.erb +27 -27
  21. data/config/locales/exception_handler.en.yml +28 -28
  22. data/db/migrate/000000_create_errors.rb +34 -34
  23. data/exception_handler.gemspec +62 -80
  24. data/lib/exception_handler.rb +55 -45
  25. data/lib/exception_handler/config.rb +116 -104
  26. data/lib/exception_handler/engine.rb +70 -61
  27. data/lib/exception_handler/version.rb +25 -0
  28. data/lib/generators/exception_handler/views_generator.rb +33 -33
  29. metadata +7 -71
  30. data/.gitattributes +0 -1
  31. data/.rspec +0 -4
  32. data/LICENSE.txt +0 -22
  33. data/spec/database.yml +0 -3
  34. data/spec/dummy/Rakefile +0 -6
  35. data/spec/dummy/app/assets/config/manifest.js +0 -4
  36. data/spec/dummy/app/assets/images/.keep +0 -0
  37. data/spec/dummy/app/assets/javascripts/application.js +0 -13
  38. data/spec/dummy/app/assets/javascripts/cable.coffee +0 -11
  39. data/spec/dummy/app/assets/javascripts/channels/.keep +0 -0
  40. data/spec/dummy/app/assets/stylesheets/application.css +0 -15
  41. data/spec/dummy/app/channels/application_cable/channel.rb +0 -5
  42. data/spec/dummy/app/channels/application_cable/connection.rb +0 -5
  43. data/spec/dummy/app/controllers/application_controller.rb +0 -5
  44. data/spec/dummy/app/controllers/concerns/.keep +0 -0
  45. data/spec/dummy/app/helpers/application_helper.rb +0 -2
  46. data/spec/dummy/app/jobs/application_job.rb +0 -2
  47. data/spec/dummy/app/mailers/application_mailer.rb +0 -4
  48. data/spec/dummy/app/models/application_record.rb +0 -3
  49. data/spec/dummy/app/models/concerns/.keep +0 -0
  50. data/spec/dummy/app/views/layouts/application.html.erb +0 -15
  51. data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
  52. data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
  53. data/spec/dummy/bin/bundle +0 -3
  54. data/spec/dummy/bin/rails +0 -4
  55. data/spec/dummy/bin/rake +0 -4
  56. data/spec/dummy/bin/setup +0 -34
  57. data/spec/dummy/bin/update +0 -29
  58. data/spec/dummy/config.ru +0 -8
  59. data/spec/dummy/config/application.rb +0 -21
  60. data/spec/dummy/config/boot.rb +0 -5
  61. data/spec/dummy/config/cable.yml +0 -10
  62. data/spec/dummy/config/database.yml +0 -25
  63. data/spec/dummy/config/environment.rb +0 -5
  64. data/spec/dummy/config/environments/development.rb +0 -62
  65. data/spec/dummy/config/environments/production.rb +0 -87
  66. data/spec/dummy/config/environments/test.rb +0 -42
  67. data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +0 -6
  68. data/spec/dummy/config/initializers/application_controller_renderer.rb +0 -6
  69. data/spec/dummy/config/initializers/assets.rb +0 -11
  70. data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
  71. data/spec/dummy/config/initializers/callback_terminator.rb +0 -6
  72. data/spec/dummy/config/initializers/cookies_serializer.rb +0 -5
  73. data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  74. data/spec/dummy/config/initializers/inflections.rb +0 -16
  75. data/spec/dummy/config/initializers/mime_types.rb +0 -4
  76. data/spec/dummy/config/initializers/per_form_csrf_tokens.rb +0 -4
  77. data/spec/dummy/config/initializers/request_forgery_protection.rb +0 -4
  78. data/spec/dummy/config/initializers/session_store.rb +0 -3
  79. data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
  80. data/spec/dummy/config/locales/en.yml +0 -23
  81. data/spec/dummy/config/puma.rb +0 -47
  82. data/spec/dummy/config/routes.rb +0 -6
  83. data/spec/dummy/config/secrets.yml +0 -22
  84. data/spec/dummy/lib/assets/.keep +0 -0
  85. data/spec/dummy/log/.keep +0 -0
  86. data/spec/dummy/public/404.html +0 -67
  87. data/spec/dummy/public/422.html +0 -67
  88. data/spec/dummy/public/500.html +0 -66
  89. data/spec/dummy/public/apple-touch-icon-precomposed.png +0 -0
  90. data/spec/dummy/public/apple-touch-icon.png +0 -0
  91. data/spec/dummy/public/favicon.ico +0 -0
  92. data/spec/exception_handler.rb +0 -22
  93. data/spec/exception_handler/exception_controller_spec.rb +0 -18
  94. data/spec/spec_helper.rb +0 -55
data/Rakefile CHANGED
@@ -1,8 +1,8 @@
1
- require "bundler/gem_tasks"
2
- require "rspec/core/rake_task"
3
-
4
- ###########################################
5
-
6
- RSpec::Core::RakeTask.new(:spec)
7
-
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ ###########################################
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
8
  task default: :spec
@@ -1,18 +1,18 @@
1
- /* ---------------------------------------------------- */
2
- /* ---------------------------------------------------- */
3
- /* _____ _____ _____ */
4
- /* / __ \/ ___/ ___| */
5
- /* | / \/\ `--.\ `--. */
6
- /* | | `--. \`--. \ */
7
- /* | \__/\/\__/ /\__/ / */
8
- /* \____/\____/\_____/ */
9
- /* */
10
- /* ---------------------------------------------------- */
11
- /* ---------------------------------------------------- */
12
- /*
13
- *= require_self
14
- *= require_tree ./styles
15
- */
16
- /* ---------------------------------------------------- */
17
- /* ---------------------------------------------------- */
18
- /* ---------------------------------------------------- */
1
+ /* ---------------------------------------------------- */
2
+ /* ---------------------------------------------------- */
3
+ /* _____ _____ _____ */
4
+ /* / __ \/ ___/ ___| */
5
+ /* | / \/\ `--.\ `--. */
6
+ /* | | `--. \`--. \ */
7
+ /* | \__/\/\__/ /\__/ / */
8
+ /* \____/\____/\_____/ */
9
+ /* */
10
+ /* ---------------------------------------------------- */
11
+ /* ---------------------------------------------------- */
12
+ /*
13
+ *= require_self
14
+ *= require_tree ./styles
15
+ */
16
+ /* ---------------------------------------------------- */
17
+ /* ---------------------------------------------------- */
18
+ /* ---------------------------------------------------- */
@@ -1,35 +1,35 @@
1
- /* ---------------------------------------------------- */
2
- /* ---------------------------------------------------- */
3
- /* Dependencies */
4
- /* ---------------------------------------------------- */
5
- /* ---------------------------------------------------- */
6
-
7
- /*
8
- *= link_tree ../../images
9
- */
10
-
11
- /* ---------------------------------------------------- */
12
- /* ---------------------------------------------------- */
13
-
14
- * { margin: 0; }
15
- html, body { height: 100%; }
16
- html {
17
- height: 100%;
18
- color: #fff;
19
- background: #010008 url(<%= asset_url("exception_handler/bg.jpg") %>) top left no-repeat;
20
- background-size: 100% 100%;
21
- box-sizing: border-box;
22
- }
23
- body {
24
- position: relative;
25
- font-family: Helvetica, Arial, Sans-Serif;
26
- font-size: 12px;
27
- text-transform: capitalize;
28
- box-sizing: border-box;
29
- overflow-x: hidden;
30
- }
31
- a { color: #fff; text-decoration: none; }
32
- a:hover { text-decoration: underline; }
33
-
34
- /* ---------------------------------------------------- */
35
- /* ---------------------------------------------------- */
1
+ /* ---------------------------------------------------- */
2
+ /* ---------------------------------------------------- */
3
+ /* Dependencies */
4
+ /* ---------------------------------------------------- */
5
+ /* ---------------------------------------------------- */
6
+
7
+ /*
8
+ *= link_tree ../../images
9
+ */
10
+
11
+ /* ---------------------------------------------------- */
12
+ /* ---------------------------------------------------- */
13
+
14
+ * { margin: 0; }
15
+ html, body { height: 100%; }
16
+ html {
17
+ height: 100%;
18
+ color: #fff;
19
+ background: #010008 url(<%= asset_url("exception_handler/bg.jpg") %>) top left no-repeat;
20
+ background-size: 100% 100%;
21
+ box-sizing: border-box;
22
+ }
23
+ body {
24
+ position: relative;
25
+ font-family: Helvetica, Arial, Sans-Serif;
26
+ font-size: 12px;
27
+ text-transform: capitalize;
28
+ box-sizing: border-box;
29
+ overflow-x: hidden;
30
+ }
31
+ a { color: #fff; text-decoration: none; }
32
+ a:hover { text-decoration: underline; }
33
+
34
+ /* ---------------------------------------------------- */
35
+ /* ---------------------------------------------------- */
@@ -1,105 +1,105 @@
1
- /* ---------------------------------------------------- */
2
- /* ---------------------------------------------------- */
3
-
4
- .exception {
5
- display: block;
6
- color: rgba(0,0,0,1);
7
- position: relative;
8
- width: 20%;
9
- top: 48%;
10
- margin: auto;
11
- border: 1px solid rgba(0,0,0,1);
12
- max-width: 400px;
13
- min-width: 350px;
14
- border-radius: 5px;
15
- box-sizing: border-box;
16
- box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.5);
17
- background: rgba(16,0,1,1);
18
- background-image: linear-gradient(to bottom, rgba(16,0,1,1) 70%,rgba(0,0,0,1) 100%);
19
- background-clip: content-box;
20
- overflow-x: hidden;
21
- overflow-y: hidden;
22
- transition: background 0.1s ease-in-out;
23
- transform: translateY(-50%);
24
- z-index: 10;
25
- }
26
- .exception::before {
27
- content: url(<%= asset_url("exception_handler/icon.png") %>) " " attr(data-response);
28
- display: block;
29
- color: rgba(255,255,255,1);
30
- font-size: 1.25em;
31
- font-weight: bold;
32
- text-transform: capitalize;
33
- padding: 1em;
34
- line-height: 10px;
35
- text-shadow: 0 1px 0 rgba(0,0,0,1);
36
- border-bottom: 1px solid rgba(122,11,11,1);
37
- vertical-align: middle;
38
- background-color: rgba(227,11,11,1);
39
- background-image: url(<%= asset_url("exception_handler/noise.png") %>), linear-gradient(to bottom, rgba(227,11,11,0) 0%,rgba(0,0,0,0.55) 100%); /* W3C */
40
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#007a07ed', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
41
- }
42
- .exception::after {
43
- content: attr(data-rails) " \203A\203A Our developers have been notified. Click here to go home.";
44
- display: block;
45
- padding: 1em;
46
- font-size: 0.8em;
47
- line-height: 11px;
48
- color: rgba(255,255,255,1);
49
- text-align: center;
50
- box-sizing: border-box;
51
-
52
- border-width: 0 1px 1px;
53
- border-color: rgba(255,255,255,0.09);
54
- border-style: solid
55
- }
56
- .exception:hover { cursor: pointer; }
57
-
58
- .exception span:before {
59
- display: block;
60
- content: url(<%= asset_url("exception_handler/alert.png") %>);
61
- padding: 3.5em 0 1em;
62
- text-align: center;
63
- }
64
- .exception span {
65
- position: relative;
66
- display: block;
67
- min-height: 288px;
68
- color: rgba(255,255,255,1);
69
- padding: 0 2.5em 3em;
70
- box-sizing: border-box;
71
- background-clip: border-box;
72
- text-align: center;
73
- background: url(<%= asset_url("exception_handler/alert.jpg") %>) top center no-repeat;
74
-
75
- border-top: 1px solid rgba(0,0,0,0.05);
76
- border-left: 1px solid rgba(255,255,255,0.08);
77
- border-right: 1px solid rgba(255,255,255,0.08);
78
- }
79
- .exception span:after {
80
- content: "";
81
- display: block;
82
- position: absolute;
83
- left: 0;
84
- top: 0;
85
- width: 100%;
86
- height: 2px;
87
-
88
- background: rgba(0,0,0,0.35);
89
- background: -moz-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
90
- background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(0,0,0,0.35)), color-stop(100%, rgba(0,0,0,0)));
91
- background: -webkit-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
92
- background: -o-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
93
- background: -ms-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
94
- background: linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
95
- filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#000000', GradientType=0 );
96
- }
97
- .exception span strong {
98
- display: block;
99
- font-size: 2em;
100
- margin: 1em 0 0.25em;
101
- text-transform: uppercase;
102
- }
103
- .exception span p { display: block; margin-top: 1.5em; font-size: 0.85em; text-decoration: underline; }
104
- /* ---------------------------------------------------- */
105
- /* ---------------------------------------------------- */
1
+ /* ---------------------------------------------------- */
2
+ /* ---------------------------------------------------- */
3
+
4
+ .exception {
5
+ display: block;
6
+ color: rgba(0,0,0,1);
7
+ position: relative;
8
+ width: 20%;
9
+ top: 48%;
10
+ margin: auto;
11
+ border: 1px solid rgba(0,0,0,1);
12
+ max-width: 400px;
13
+ min-width: 350px;
14
+ border-radius: 5px;
15
+ box-sizing: border-box;
16
+ box-shadow: 0px 0px 2px 0px rgba(0,0,0,0.5);
17
+ background: rgba(16,0,1,1);
18
+ background-image: linear-gradient(to bottom, rgba(16,0,1,1) 70%,rgba(0,0,0,1) 100%);
19
+ background-clip: content-box;
20
+ overflow-x: hidden;
21
+ overflow-y: hidden;
22
+ transition: background 0.1s ease-in-out;
23
+ transform: translateY(-50%);
24
+ z-index: 10;
25
+ }
26
+ .exception::before {
27
+ content: url(<%= asset_url("exception_handler/icon.png") %>) " " attr(data-response);
28
+ display: block;
29
+ color: rgba(255,255,255,1);
30
+ font-size: 1.25em;
31
+ font-weight: bold;
32
+ text-transform: capitalize;
33
+ padding: 1em;
34
+ line-height: 10px;
35
+ text-shadow: 0 1px 0 rgba(0,0,0,1);
36
+ border-bottom: 1px solid rgba(122,11,11,1);
37
+ vertical-align: middle;
38
+ background-color: rgba(227,11,11,1);
39
+ background-image: url(<%= asset_url("exception_handler/noise.png") %>), linear-gradient(to bottom, rgba(227,11,11,0) 0%,rgba(0,0,0,0.55) 100%); /* W3C */
40
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#007a07ed', endColorstr='#000000',GradientType=0 ); /* IE6-9 */
41
+ }
42
+ .exception::after {
43
+ content: attr(data-rails) " \203A\203A Our developers have been notified. Click here to go home.";
44
+ display: block;
45
+ padding: 1em;
46
+ font-size: 0.8em;
47
+ line-height: 11px;
48
+ color: rgba(255,255,255,1);
49
+ text-align: center;
50
+ box-sizing: border-box;
51
+
52
+ border-width: 0 1px 1px;
53
+ border-color: rgba(255,255,255,0.09);
54
+ border-style: solid
55
+ }
56
+ .exception:hover { cursor: pointer; }
57
+
58
+ .exception span:before {
59
+ display: block;
60
+ content: url(<%= asset_url("exception_handler/alert.png") %>);
61
+ padding: 3.5em 0 1em;
62
+ text-align: center;
63
+ }
64
+ .exception span {
65
+ position: relative;
66
+ display: block;
67
+ min-height: 288px;
68
+ color: rgba(255,255,255,1);
69
+ padding: 0 2.5em 3em;
70
+ box-sizing: border-box;
71
+ background-clip: border-box;
72
+ text-align: center;
73
+ background: url(<%= asset_url("exception_handler/alert.jpg") %>) top center no-repeat;
74
+
75
+ border-top: 1px solid rgba(0,0,0,0.05);
76
+ border-left: 1px solid rgba(255,255,255,0.08);
77
+ border-right: 1px solid rgba(255,255,255,0.08);
78
+ }
79
+ .exception span:after {
80
+ content: "";
81
+ display: block;
82
+ position: absolute;
83
+ left: 0;
84
+ top: 0;
85
+ width: 100%;
86
+ height: 2px;
87
+
88
+ background: rgba(0,0,0,0.35);
89
+ background: -moz-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
90
+ background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(0,0,0,0.35)), color-stop(100%, rgba(0,0,0,0)));
91
+ background: -webkit-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
92
+ background: -o-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
93
+ background: -ms-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
94
+ background: linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
95
+ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#000000', GradientType=0 );
96
+ }
97
+ .exception span strong {
98
+ display: block;
99
+ font-size: 2em;
100
+ margin: 1em 0 0.25em;
101
+ text-transform: uppercase;
102
+ }
103
+ .exception span p { display: block; margin-top: 1.5em; font-size: 0.85em; text-decoration: underline; }
104
+ /* ---------------------------------------------------- */
105
+ /* ---------------------------------------------------- */
@@ -1,24 +1,24 @@
1
- /* ---------------------------------------------------- */
2
- /* ---------------------------------------------------- */
3
-
4
- footer {
5
- display: block;
6
- position: absolute;
7
- bottom: 0;
8
- width: 100%;
9
- font-size: 2em;
10
- text-align: center;
11
- vertical-align: middle;
12
- }
13
- footer a {
14
- display: inline-block;
15
- margin-right: -4px;
16
- padding: 1.5em 0.3em;
17
- vertical-align: middle;
18
- transition: opacity 0.15s ease-in-out;
19
- }
20
- footer a:hover { text-decoration: none; }
21
- footer a img { width: 30px; vertical-align: middle; }
22
-
23
- /* ---------------------------------------------------- */
24
- /* ---------------------------------------------------- */
1
+ /* ---------------------------------------------------- */
2
+ /* ---------------------------------------------------- */
3
+
4
+ footer {
5
+ display: block;
6
+ position: absolute;
7
+ bottom: 0;
8
+ width: 100%;
9
+ font-size: 2em;
10
+ text-align: center;
11
+ vertical-align: middle;
12
+ }
13
+ footer a {
14
+ display: inline-block;
15
+ margin-right: -4px;
16
+ padding: 1.5em 0.3em;
17
+ vertical-align: middle;
18
+ transition: opacity 0.15s ease-in-out;
19
+ }
20
+ footer a:hover { text-decoration: none; }
21
+ footer a img { width: 30px; vertical-align: middle; }
22
+
23
+ /* ---------------------------------------------------- */
24
+ /* ---------------------------------------------------- */
@@ -1,5 +1,5 @@
1
- /* Responsive */
2
- @media screen and (max-width: 950px) {
3
- html { background-size: cover !important; }
4
- .container .error { width: 55% !important; }
5
- }
1
+ /* Responsive */
2
+ @media screen and (max-width: 950px) {
3
+ html { background-size: cover !important; }
4
+ .container .error { width: 55% !important; }
5
+ }
@@ -1,59 +1,59 @@
1
- module ExceptionHandler
2
- class ExceptionsController < ApplicationController
3
-
4
- # => Response
5
- # => http://www.justinweiss.com/articles/respond-to-without-all-the-pain/
6
- respond_to :html, :js, :json, :xml
7
-
8
- # => CSRF
9
- protect_from_forgery
10
-
11
- # => Devise
12
- # => http://stackoverflow.com/a/38531245/1143732
13
- skip_before_action :authenticate_user!, raise: false
14
-
15
- ##################################
16
- ##################################
17
-
18
- # => Definitions
19
- # => Exception model (tied to DB)
20
- before_action { |e| @exception = ExceptionHandler::Exception.new request: e.request }
21
- before_action { @exception.save if @exception.valid? && ExceptionHandler.config.try(:db) }
22
-
23
- # => Response format (required for non-standard formats (.css / .gz etc))
24
- # => request.format required until responders updates with wildcard / failsafe (:all)
25
- before_action { |e| e.request.format = :html unless self.class.respond_to.include? e.request.format }
26
-
27
- # => Routes
28
- # => Removes need for "main_app" prefix in routes
29
- # => http://stackoverflow.com/a/40251516/1143732
30
- helper Rails.application.routes.url_helpers
31
-
32
- # => Layout
33
- # => Layouts only 400 / 500 because they are the only error responses (300 is redirect)
34
- # => http://guides.rubyonrails.org/layouts_and_rendering.html#the-status-option
35
- # => Layout proc kills "nil" inheritance, needs to be method for now
36
- layout :layout
37
-
38
- ####################
39
- # Action #
40
- ####################
41
-
42
- def show
43
- respond_with @exception, status: @exception.status
44
- end
45
-
46
- ##################################
47
- ##################################
48
-
49
- private
50
-
51
- def layout
52
- ExceptionHandler.config.layouts[@exception.status]
53
- end
54
-
55
- ##################################
56
- ##################################
57
-
58
- end
59
- end
1
+ module ExceptionHandler
2
+ class ExceptionsController < ApplicationController
3
+
4
+ # => Response
5
+ # => http://www.justinweiss.com/articles/respond-to-without-all-the-pain/
6
+ respond_to :html, :js, :json, :xml
7
+
8
+ # => CSRF
9
+ protect_from_forgery
10
+
11
+ # => Devise
12
+ # => http://stackoverflow.com/a/38531245/1143732
13
+ skip_before_action :authenticate_user!, raise: false
14
+
15
+ ##################################
16
+ ##################################
17
+
18
+ # => Definitions
19
+ # => Exception model (tied to DB)
20
+ before_action { |e| @exception = ExceptionHandler::Exception.new request: e.request }
21
+ before_action { @exception.save if @exception.valid? && ExceptionHandler.config.try(:db) }
22
+
23
+ # => Response format (required for non-standard formats (.css / .gz etc))
24
+ # => request.format required until responders updates with wildcard / failsafe (:all)
25
+ before_action { |e| e.request.format = :html unless self.class.respond_to.include? e.request.format }
26
+
27
+ # => Routes
28
+ # => Removes need for "main_app" prefix in routes
29
+ # => http://stackoverflow.com/a/40251516/1143732
30
+ helper Rails.application.routes.url_helpers
31
+
32
+ # => Layout
33
+ # => Layouts only 400 / 500 because they are the only error responses (300 is redirect)
34
+ # => http://guides.rubyonrails.org/layouts_and_rendering.html#the-status-option
35
+ # => Layout proc kills "nil" inheritance, needs to be method for now
36
+ layout :layout
37
+
38
+ ####################
39
+ # Action #
40
+ ####################
41
+
42
+ def show
43
+ respond_with @exception, status: @exception.status
44
+ end
45
+
46
+ ##################################
47
+ ##################################
48
+
49
+ private
50
+
51
+ def layout
52
+ ExceptionHandler.config.layouts[@exception.status]
53
+ end
54
+
55
+ ##################################
56
+ ##################################
57
+
58
+ end
59
+ end