mosaic-errors 1.0.0 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +5 -4
- data/app/controllers/errors/application_controller.rb +5 -0
- data/app/controllers/errors/errors_controller.rb +14 -0
- data/app/helpers/errors/application_helper.rb +4 -0
- data/{lib/generators/templates → app/views/errors/errors}/internal_server_error.html.haml +0 -0
- data/{lib/generators/templates → app/views/errors/errors}/not_found.html.haml +0 -0
- data/app/views/errors/errors/unprocessable_entity.html.haml +2 -0
- data/app/views/errors/layouts/application.html +14 -0
- data/config/routes.rb +5 -0
- data/lib/mosaic-errors.rb +0 -1
- data/lib/mosaic/errors.rb +1 -65
- data/lib/mosaic/errors/engine.rb +4 -0
- data/lib/mosaic/errors/version.rb +1 -1
- metadata +11 -11
- data/lib/generators/error_pages_generator.rb +0 -13
data/.gitignore
CHANGED
@@ -10,6 +10,7 @@ doc
|
|
10
10
|
|
11
11
|
# bundler
|
12
12
|
.bundle
|
13
|
+
Gemfile.lock
|
13
14
|
|
14
15
|
# jeweler generated
|
15
16
|
pkg
|
@@ -27,11 +28,11 @@ pkg
|
|
27
28
|
#
|
28
29
|
# For MacOS:
|
29
30
|
#
|
30
|
-
|
31
|
+
.DS_Store
|
31
32
|
|
32
33
|
# For TextMate
|
33
|
-
|
34
|
-
|
34
|
+
*.tmproj
|
35
|
+
tmtags
|
35
36
|
|
36
37
|
# For emacs:
|
37
38
|
#*~
|
@@ -39,7 +40,7 @@ pkg
|
|
39
40
|
#.\#*
|
40
41
|
|
41
42
|
# For vim:
|
42
|
-
|
43
|
+
*.swp
|
43
44
|
|
44
45
|
# For redcar:
|
45
46
|
#.redcar
|
File without changes
|
File without changes
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>Errors</title>
|
5
|
+
<%= stylesheet_link_tag "errors/application", :media => "all" %>
|
6
|
+
<%= javascript_include_tag "errors/application" %>
|
7
|
+
<%= csrf_meta_tags %>
|
8
|
+
</head>
|
9
|
+
<body>
|
10
|
+
|
11
|
+
<%= yield %>
|
12
|
+
|
13
|
+
</body>
|
14
|
+
</html>
|
data/config/routes.rb
ADDED
data/lib/mosaic-errors.rb
CHANGED
data/lib/mosaic/errors.rb
CHANGED
@@ -1,66 +1,2 @@
|
|
1
|
-
|
2
|
-
module Errors
|
3
|
-
@@include_stack_trace = false
|
1
|
+
require "mosaic/errors/engine"
|
4
2
|
|
5
|
-
def self.include_stack_trace!
|
6
|
-
@@include_stack_trace = true
|
7
|
-
end
|
8
|
-
|
9
|
-
def self.included(controller)
|
10
|
-
controller.extend(ClassMethods)
|
11
|
-
controller.rescue_from Exception do |exception|
|
12
|
-
render_application_error_template_for_exception(exception)
|
13
|
-
Rails.logger.error exception.backtrace.join("\n") if include_stack_trace?
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
def routing_error
|
18
|
-
render_application_error_template :not_found
|
19
|
-
end
|
20
|
-
|
21
|
-
module ClassMethods
|
22
|
-
DEFAULT_RESCUE_RESPONSE = :internal_server_error
|
23
|
-
|
24
|
-
DEFAULT_RESCUE_RESPONSES = {
|
25
|
-
'ActionController::RoutingError' => :not_found,
|
26
|
-
'ActionController::UnknownAction' => :not_found,
|
27
|
-
'ActiveRecord::RecordNotFound' => :not_found,
|
28
|
-
'ActiveRecord::StaleObjectError' => :conflict,
|
29
|
-
'ActiveRecord::RecordInvalid' => :unprocessable_entity,
|
30
|
-
'ActiveRecord::RecordNotSaved' => :unprocessable_entity,
|
31
|
-
'ActionController::MethodNotAllowed' => :method_not_allowed,
|
32
|
-
'ActionController::NotImplemented' => :not_implemented,
|
33
|
-
'ActionController::InvalidAuthenticityToken' => :unprocessable_entity
|
34
|
-
}
|
35
|
-
|
36
|
-
def rescue_responses
|
37
|
-
@rescue_responses ||= Hash.new(DEFAULT_RESCUE_RESPONSE).merge(DEFAULT_RESCUE_RESPONSES)
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
protected
|
42
|
-
def render_application_error_template(status)
|
43
|
-
render :template => "errors/#{status}", :status => status
|
44
|
-
rescue ActionView::MissingTemplate
|
45
|
-
render :nothing => true, :status => status
|
46
|
-
end
|
47
|
-
|
48
|
-
def render_application_error_template_for_exception(exception)
|
49
|
-
status = self.class.rescue_responses[exception.class.name]
|
50
|
-
send_exception_notification(exception) if status == :internal_server_error || status == :not_found
|
51
|
-
render_application_error_template status
|
52
|
-
end
|
53
|
-
|
54
|
-
def send_exception_notification(exception)
|
55
|
-
if defined? notify_airbrake
|
56
|
-
notify_airbrake(exception)
|
57
|
-
elsif defined? notify_hoptoad
|
58
|
-
notify_hoptoad(exception)
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def include_stack_trace?
|
63
|
-
@@include_stack_trace
|
64
|
-
end
|
65
|
-
end
|
66
|
-
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mosaic-errors
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 2.0.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: haml
|
@@ -74,12 +74,18 @@ files:
|
|
74
74
|
- README.md
|
75
75
|
- Rakefile
|
76
76
|
- VERSION
|
77
|
+
- app/controllers/errors/application_controller.rb
|
78
|
+
- app/controllers/errors/errors_controller.rb
|
79
|
+
- app/helpers/errors/application_helper.rb
|
80
|
+
- app/views/errors/errors/internal_server_error.html.haml
|
81
|
+
- app/views/errors/errors/not_found.html.haml
|
82
|
+
- app/views/errors/errors/unprocessable_entity.html.haml
|
83
|
+
- app/views/errors/layouts/application.html
|
84
|
+
- config/routes.rb
|
77
85
|
- install.rb
|
78
|
-
- lib/generators/error_pages_generator.rb
|
79
|
-
- lib/generators/templates/internal_server_error.html.haml
|
80
|
-
- lib/generators/templates/not_found.html.haml
|
81
86
|
- lib/mosaic-errors.rb
|
82
87
|
- lib/mosaic/errors.rb
|
88
|
+
- lib/mosaic/errors/engine.rb
|
83
89
|
- lib/mosaic/errors/version.rb
|
84
90
|
- lib/mosaic_errors.rb
|
85
91
|
- mosaic-errors.gemspec
|
@@ -98,18 +104,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
98
104
|
- - ! '>='
|
99
105
|
- !ruby/object:Gem::Version
|
100
106
|
version: '0'
|
101
|
-
segments:
|
102
|
-
- 0
|
103
|
-
hash: -4474960627516075816
|
104
107
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
105
108
|
none: false
|
106
109
|
requirements:
|
107
110
|
- - ! '>='
|
108
111
|
- !ruby/object:Gem::Version
|
109
112
|
version: '0'
|
110
|
-
segments:
|
111
|
-
- 0
|
112
|
-
hash: -4474960627516075816
|
113
113
|
requirements: []
|
114
114
|
rubyforge_project:
|
115
115
|
rubygems_version: 1.8.23
|
@@ -1,13 +0,0 @@
|
|
1
|
-
class ErrorPagesGenerator < Rails::Generators::Base
|
2
|
-
desc "adds error pages haml to the application and add routes"
|
3
|
-
source_root File.expand_path("../templates", __FILE__)
|
4
|
-
|
5
|
-
def copy_error_pages
|
6
|
-
copy_file "internal_server_error.html.haml", "app/views/errors/internal_server_error.html.haml"
|
7
|
-
copy_file "not_found.html.haml", "app/views/errors/not_found.html.haml"
|
8
|
-
end
|
9
|
-
|
10
|
-
def add_route
|
11
|
-
route "match '*path', :to => 'application#routing_error'"
|
12
|
-
end
|
13
|
-
end
|