exception_handler 0.7.5 → 0.8.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.coveralls.yml +1 -0
- data/.gitignore +51 -33
- data/.rspec +3 -4
- data/.slugignore +7 -0
- data/.travis.yml +13 -5
- data/Gemfile +16 -13
- data/README.md +643 -443
- data/Rakefile +7 -7
- data/app/assets/stylesheets/exception_handler.css.erb +23 -18
- data/app/assets/stylesheets/styles/_base.css.erb +28 -35
- data/app/assets/stylesheets/styles/_exception.css.erb +106 -105
- data/app/assets/stylesheets/styles/_footer.css.erb +24 -24
- data/app/assets/stylesheets/styles/_responsive.css +5 -5
- data/app/controllers/exception_handler/exceptions_controller.rb +66 -55
- data/app/mailers/exception_handler/exception_mailer.rb +17 -17
- data/app/models/exception_handler/exception.rb +200 -191
- data/app/views/exception_handler/exceptions/show.html.erb +3 -3
- data/app/views/exception_handler/mailers/layout.haml +8 -8
- data/app/views/exception_handler/mailers/layout.text.erb +1 -1
- data/app/views/exception_handler/mailers/new_exception.erb +4 -4
- data/app/views/layouts/exception.html.erb +32 -27
- data/app/views/layouts/mailer.html.erb +5 -0
- data/app/views/layouts/mailer.text.erb +1 -0
- data/config/locales/exception_handler.en.yml +28 -29
- data/config/routes.rb +42 -0
- data/db/migrate/000000_create_errors.rb +34 -34
- data/exception_handler.gemspec +64 -80
- data/lib/exception_handler.rb +56 -45
- data/lib/exception_handler/config.rb +185 -103
- data/lib/exception_handler/engine.rb +78 -60
- data/lib/exception_handler/version.rb +25 -0
- data/lib/generators/exception_handler/views_generator.rb +33 -33
- data/spec/controllers/controller_spec.rb +107 -0
- data/spec/dummy/.rspec +1 -0
- data/spec/dummy/.ruby-version +1 -0
- data/spec/dummy/Rakefile +6 -6
- data/spec/dummy/app/assets/config/manifest.js +3 -4
- data/spec/dummy/app/assets/javascripts/application.js +15 -13
- data/spec/dummy/app/assets/javascripts/cable.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +15 -15
- data/spec/dummy/app/channels/application_cable/channel.rb +4 -5
- data/spec/dummy/app/channels/application_cable/connection.rb +4 -5
- data/spec/dummy/app/controllers/application_controller.rb +2 -5
- data/spec/dummy/app/helpers/application_helper.rb +2 -2
- data/spec/dummy/app/jobs/application_job.rb +2 -2
- data/spec/dummy/app/mailers/application_mailer.rb +4 -4
- data/spec/dummy/app/models/application_record.rb +3 -3
- data/spec/dummy/app/views/layouts/application.html.erb +15 -15
- data/spec/dummy/app/views/layouts/mailer.html.erb +13 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +1 -1
- data/spec/dummy/bin/bundle +3 -3
- data/spec/dummy/bin/rails +4 -4
- data/spec/dummy/bin/rake +4 -4
- data/spec/dummy/bin/setup +36 -34
- data/spec/dummy/bin/update +31 -29
- data/spec/dummy/bin/yarn +11 -0
- data/spec/dummy/config.ru +5 -8
- data/spec/dummy/config/application.rb +18 -21
- data/spec/dummy/config/boot.rb +5 -5
- data/spec/dummy/config/cable.yml +10 -10
- data/spec/dummy/config/database.yml +25 -25
- data/spec/dummy/config/environment.rb +5 -5
- data/spec/dummy/config/environments/development.rb +61 -62
- data/spec/dummy/config/environments/production.rb +94 -87
- data/spec/dummy/config/environments/test.rb +46 -42
- data/spec/dummy/config/initializers/application_controller_renderer.rb +8 -6
- data/spec/dummy/config/initializers/assets.rb +14 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/content_security_policy.rb +25 -0
- data/spec/dummy/config/initializers/cookies_serializer.rb +5 -5
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -4
- data/spec/dummy/config/initializers/inflections.rb +16 -16
- data/spec/dummy/config/initializers/mime_types.rb +4 -4
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +33 -23
- data/spec/dummy/config/puma.rb +34 -47
- data/spec/dummy/config/routes.rb +3 -6
- data/spec/dummy/config/storage.yml +34 -0
- data/spec/dummy/package.json +5 -0
- data/spec/dummy/public/404.html +67 -67
- data/spec/dummy/public/422.html +67 -67
- data/spec/dummy/public/500.html +66 -66
- data/spec/dummy/spec/rails_helper.rb +57 -0
- data/spec/dummy/spec/spec_helper.rb +100 -0
- data/spec/dummy/storage/.keep +0 -0
- data/spec/features/asset_spec.rb +61 -0
- data/spec/features/config_spec.rb +51 -0
- data/spec/features/engine_spec.rb +180 -0
- data/spec/mailers/mailer_spec.rb +26 -0
- data/spec/models/model_spec.rb +26 -0
- data/spec/routing/routing_spec.rb +85 -0
- data/spec/spec_helper.rb +101 -55
- data/spec/views/views_spec.rb +29 -0
- metadata +54 -28
- data/.gitattributes +0 -1
- data/LICENSE.txt +0 -22
- data/app/assets/images/exception_handler/bg.jpg +0 -0
- data/app/assets/images/exception_handler/bg_overlay.png +0 -0
- data/spec/database.yml +0 -3
- data/spec/dummy/app/assets/javascripts/cable.coffee +0 -11
- data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +0 -6
- data/spec/dummy/config/initializers/callback_terminator.rb +0 -6
- data/spec/dummy/config/initializers/per_form_csrf_tokens.rb +0 -4
- data/spec/dummy/config/initializers/request_forgery_protection.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/exception_handler.rb +0 -22
- data/spec/exception_handler/exception_controller_spec.rb +0 -18
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,23 @@
|
|
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
|
+
/*
|
19
|
+
*= link_tree ../images
|
20
|
+
*/
|
21
|
+
/* ---------------------------------------------------- */
|
22
|
+
/* ---------------------------------------------------- */
|
23
|
+
/* ---------------------------------------------------- */
|
@@ -1,35 +1,28 @@
|
|
1
|
-
/* ---------------------------------------------------- */
|
2
|
-
/* ---------------------------------------------------- */
|
3
|
-
/* Dependencies */
|
4
|
-
/* ---------------------------------------------------- */
|
5
|
-
/* ---------------------------------------------------- */
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
box-sizing: border-box;
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
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
|
+
* { margin: 0; }
|
8
|
+
html, body { height: 100%; }
|
9
|
+
html {
|
10
|
+
height: 100%;
|
11
|
+
color: #fff;
|
12
|
+
background: #121212;
|
13
|
+
background-size: 100% 100%;
|
14
|
+
box-sizing: border-box;
|
15
|
+
}
|
16
|
+
body {
|
17
|
+
position: relative;
|
18
|
+
font-family: Helvetica, Arial, Sans-Serif;
|
19
|
+
font-size: 12px;
|
20
|
+
text-transform: capitalize;
|
21
|
+
box-sizing: border-box;
|
22
|
+
overflow-x: hidden;
|
23
|
+
}
|
24
|
+
a { color: #fff; text-decoration: none; }
|
25
|
+
a:hover { text-decoration: underline; }
|
26
|
+
|
27
|
+
/* ---------------------------------------------------- */
|
28
|
+
/* ---------------------------------------------------- */
|
@@ -1,105 +1,106 @@
|
|
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
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
border-
|
77
|
-
border-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
background:
|
90
|
-
background: -
|
91
|
-
background: -webkit-
|
92
|
-
background: -
|
93
|
-
background: -
|
94
|
-
background: linear-gradient(
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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
|
+
.exception:hover:after { text-decoration: underline; }
|
58
|
+
|
59
|
+
.exception span:before {
|
60
|
+
display: block;
|
61
|
+
content: url(<%= asset_url("exception_handler/alert.png") %>);
|
62
|
+
padding: 3.5em 0 1em;
|
63
|
+
text-align: center;
|
64
|
+
}
|
65
|
+
.exception span {
|
66
|
+
position: relative;
|
67
|
+
display: block;
|
68
|
+
min-height: 288px;
|
69
|
+
color: rgba(255,255,255,1);
|
70
|
+
padding: 0 2.5em 3em;
|
71
|
+
box-sizing: border-box;
|
72
|
+
background-clip: border-box;
|
73
|
+
text-align: center;
|
74
|
+
background: url(<%= asset_url("exception_handler/alert.jpg") %>) top center no-repeat;
|
75
|
+
|
76
|
+
border-top: 1px solid rgba(0,0,0,0.05);
|
77
|
+
border-left: 1px solid rgba(255,255,255,0.08);
|
78
|
+
border-right: 1px solid rgba(255,255,255,0.08);
|
79
|
+
}
|
80
|
+
.exception span:after {
|
81
|
+
content: "";
|
82
|
+
display: block;
|
83
|
+
position: absolute;
|
84
|
+
left: 0;
|
85
|
+
top: 0;
|
86
|
+
width: 100%;
|
87
|
+
height: 2px;
|
88
|
+
|
89
|
+
background: rgba(0,0,0,0.35);
|
90
|
+
background: -moz-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
|
91
|
+
background: -webkit-gradient(left top, left bottom, color-stop(0%, rgba(0,0,0,0.35)), color-stop(100%, rgba(0,0,0,0)));
|
92
|
+
background: -webkit-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
|
93
|
+
background: -o-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
|
94
|
+
background: -ms-linear-gradient(top, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
|
95
|
+
background: linear-gradient(to bottom, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0) 100%);
|
96
|
+
filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#000000', endColorstr='#000000', GradientType=0 );
|
97
|
+
}
|
98
|
+
.exception span strong {
|
99
|
+
display: block;
|
100
|
+
font-size: 2em;
|
101
|
+
margin: 1em 0 0.25em;
|
102
|
+
text-transform: uppercase;
|
103
|
+
}
|
104
|
+
.exception span p { display: block; margin-top: 1.5em; font-size: 0.85em; text-decoration: underline; }
|
105
|
+
/* ---------------------------------------------------- */
|
106
|
+
/* ---------------------------------------------------- */
|
@@ -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,55 +1,66 @@
|
|
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
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
# =>
|
20
|
-
|
21
|
-
before_action {
|
22
|
-
|
23
|
-
# =>
|
24
|
-
# =>
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# =>
|
29
|
-
# =>
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
#
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
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
|
+
# Actions #
|
40
|
+
####################
|
41
|
+
|
42
|
+
# => General Show Functionality
|
43
|
+
# => Introduced new "action" config option in 0.8.0.0
|
44
|
+
def show
|
45
|
+
respond_with @exception, status: @exception.status
|
46
|
+
end
|
47
|
+
|
48
|
+
##################################
|
49
|
+
##################################
|
50
|
+
|
51
|
+
private
|
52
|
+
|
53
|
+
# => Pulls from Exception class
|
54
|
+
# => Spanner in the works is nil
|
55
|
+
# => .present? validates against empty strings (IE a string is present)
|
56
|
+
# => .nil? validates to see if the returned data is "nil"
|
57
|
+
# => nil required to facilitate inheritance of the layout w/ ApplicationController
|
58
|
+
def layout option = ExceptionHandler.config.options(@exception.status, :layout)
|
59
|
+
(option.present? || option.nil?) ? option : 'exception'
|
60
|
+
end
|
61
|
+
|
62
|
+
##################################
|
63
|
+
##################################
|
64
|
+
|
65
|
+
end
|
66
|
+
end
|