exception_handler 0.6.5 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +33 -33
- data/.rspec +3 -3
- data/.travis.yml +5 -5
- data/Gemfile +13 -13
- data/LICENSE.txt +22 -22
- data/README.md +349 -341
- data/Rakefile +7 -7
- data/app/assets/images/{favicon.ico → exception_handler.ico} +0 -0
- data/app/assets/images/exception_handler/alert.jpg +0 -0
- data/app/assets/images/exception_handler/bg.jpg +0 -0
- data/app/assets/images/exception_handler/favicon.ico +0 -0
- data/app/assets/images/exception_handler/icon.png +0 -0
- data/app/assets/stylesheets/exception_handler.css.erb +8 -8
- data/app/assets/stylesheets/styles/_base.css.erb +35 -34
- data/app/assets/stylesheets/styles/_exception.css.erb +105 -103
- data/app/assets/stylesheets/styles/_footer.css.erb +24 -27
- data/app/assets/stylesheets/styles/_responsive.css +5 -5
- data/app/controllers/exception_handler/exception_controller.rb +45 -38
- data/app/mailers/exception_handler/exception_mailer.rb +16 -16
- data/app/models/exception_handler/exception.rb +191 -191
- data/app/views/exception_handler/exception/show.html.erb +1 -1
- data/app/views/exception_handler/mailers/new_exception.erb +4 -4
- data/app/views/layouts/exception.html.erb +27 -21
- data/config/locales/exception_handler.en.yml +13 -13
- data/exception_handler.gemspec +80 -84
- data/lib/exception_handler.rb +32 -29
- data/lib/exception_handler/config.rb +80 -66
- data/lib/exception_handler/engine.rb +44 -36
- data/lib/generators/exception_handler/migration_generator.rb +55 -55
- data/lib/generators/exception_handler/views_generator.rb +42 -42
- data/lib/generators/templates/migration.rb.erb +16 -16
- data/spec/database.yml +2 -2
- data/spec/dummy/Rakefile +6 -6
- data/spec/dummy/app/assets/config/manifest.js +4 -4
- data/spec/dummy/app/assets/javascripts/application.js +13 -13
- data/spec/dummy/app/assets/javascripts/cable.coffee +11 -11
- data/spec/dummy/app/assets/stylesheets/application.css +15 -15
- data/spec/dummy/app/channels/application_cable/channel.rb +5 -5
- data/spec/dummy/app/channels/application_cable/connection.rb +5 -5
- data/spec/dummy/app/controllers/application_controller.rb +5 -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 +34 -34
- data/spec/dummy/bin/update +29 -29
- data/spec/dummy/config.ru +8 -8
- data/spec/dummy/config/application.rb +21 -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 +62 -62
- data/spec/dummy/config/environments/production.rb +87 -87
- data/spec/dummy/config/environments/test.rb +42 -42
- data/spec/dummy/config/initializers/active_record_belongs_to_required_by_default.rb +6 -6
- data/spec/dummy/config/initializers/application_controller_renderer.rb +6 -6
- data/spec/dummy/config/initializers/assets.rb +11 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -7
- data/spec/dummy/config/initializers/callback_terminator.rb +6 -6
- 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/per_form_csrf_tokens.rb +4 -4
- data/spec/dummy/config/initializers/request_forgery_protection.rb +4 -4
- data/spec/dummy/config/initializers/session_store.rb +3 -3
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -14
- data/spec/dummy/config/locales/en.yml +23 -23
- data/spec/dummy/config/puma.rb +47 -47
- data/spec/dummy/config/routes.rb +6 -6
- data/spec/dummy/config/secrets.yml +22 -22
- 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/exception_handler.rb +21 -21
- data/spec/exception_handler/exception_controller_spec.rb +18 -0
- data/spec/spec_helper.rb +54 -54
- metadata +11 -8
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
|
File without changes
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
@@ -7,12 +7,12 @@
|
|
7
7
|
/* | \__/\/\__/ /\__/ / */
|
8
8
|
/* \____/\____/\_____/ */
|
9
9
|
/* */
|
10
|
-
/* ---------------------------------------------------- */
|
11
|
-
/* ---------------------------------------------------- */
|
12
|
-
/*
|
13
|
-
*= require_self
|
14
|
-
*= require_tree ./styles
|
15
|
-
*/
|
16
10
|
/* ---------------------------------------------------- */
|
17
|
-
/* ---------------------------------------------------- */
|
18
|
-
/*
|
11
|
+
/* ---------------------------------------------------- */
|
12
|
+
/*
|
13
|
+
*= require_self
|
14
|
+
*= require_tree ./styles
|
15
|
+
*/
|
16
|
+
/* ---------------------------------------------------- */
|
17
|
+
/* ---------------------------------------------------- */
|
18
|
+
/* ---------------------------------------------------- */
|
@@ -1,34 +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
|
-
|
25
|
-
font-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
a:
|
32
|
-
|
33
|
-
|
34
|
-
/* ---------------------------------------------------- */
|
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,103 +1,105 @@
|
|
1
|
-
/* ---------------------------------------------------- */
|
2
|
-
/* ---------------------------------------------------- */
|
3
|
-
|
4
|
-
.exception {
|
5
|
-
display:
|
6
|
-
color:
|
7
|
-
position:
|
8
|
-
width:
|
9
|
-
top:
|
10
|
-
margin:
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
background-clip:
|
20
|
-
|
21
|
-
overflow-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
}
|
26
|
-
.exception::before {
|
27
|
-
content:
|
28
|
-
display: block;
|
29
|
-
color:
|
30
|
-
font-size: 1.
|
31
|
-
font-weight: bold;
|
32
|
-
text-transform: capitalize;
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
background-
|
39
|
-
background-image:
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
.
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
.
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
.
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
background:
|
72
|
-
|
73
|
-
background:
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
}
|
79
|
-
.exception span {
|
80
|
-
|
81
|
-
display: block;
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
.
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
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-siing: 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,27 +1,24 @@
|
|
1
|
-
/* ---------------------------------------------------- */
|
2
|
-
/* ---------------------------------------------------- */
|
3
|
-
|
4
|
-
footer {
|
5
|
-
display: block;
|
6
|
-
position: absolute;
|
7
|
-
bottom: 0;
|
8
|
-
width: 100%;
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
/* ---------------------------------------------------- */
|
27
|
-
/* ---------------------------------------------------- */
|
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,38 +1,45 @@
|
|
1
|
-
module ExceptionHandler
|
2
|
-
class ExceptionController < ApplicationController
|
3
|
-
|
4
|
-
# => Response
|
5
|
-
# => http://www.justinweiss.com/articles/respond-to-without-all-the-pain/
|
6
|
-
respond_to :html, :
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
# =>
|
24
|
-
# =>
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
#
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
1
|
+
module ExceptionHandler
|
2
|
+
class ExceptionController < 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
|
+
# => Definitions
|
15
|
+
# => Exception model (tied to DB)
|
16
|
+
before_action { |e| @exception = ExceptionHandler::Exception.new request: e.request }
|
17
|
+
before_action { @exception.save if @exception.valid? && ExceptionHandler.config.try(:db) }
|
18
|
+
|
19
|
+
# => Response format (required for non-standard formats (.css / .gz etc))
|
20
|
+
# => request.format required until responders updates with wildcard / failsafe (:all)
|
21
|
+
before_action { |e| e.request.format = :html unless self.class.respond_to.include? e.request.format }
|
22
|
+
|
23
|
+
# => Routes
|
24
|
+
# => Removes need for "main_app" prefix in routes
|
25
|
+
# => http://stackoverflow.com/a/40251516/1143732
|
26
|
+
helper Rails.application.routes.url_helpers
|
27
|
+
|
28
|
+
# => Layout
|
29
|
+
# => Layouts only 400 / 500 because they are the only error responses (300 is redirect)
|
30
|
+
# => http://guides.rubyonrails.org/layouts_and_rendering.html#the-status-option
|
31
|
+
# => Layout proc kills inheritance, needs to be method for now
|
32
|
+
layout :layout
|
33
|
+
|
34
|
+
####################
|
35
|
+
# Action #
|
36
|
+
####################
|
37
|
+
|
38
|
+
def show
|
39
|
+
respond_with @exception, status: @exception.status
|
40
|
+
end
|
41
|
+
|
42
|
+
##################################
|
36
43
|
##################################
|
37
44
|
|
38
45
|
private
|
@@ -40,6 +47,6 @@ module ExceptionHandler
|
|
40
47
|
def layout
|
41
48
|
ExceptionHandler.config.layouts[ @exception.status[0] + "00" ]
|
42
49
|
end
|
43
|
-
|
44
|
-
end
|
45
|
-
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|