rails_exception_handler 1.1.1 → 1.1.2
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.
- data/HISTORY +8 -4
- data/README.markdown +5 -3
- data/Rakefile +2 -0
- data/VERSION +1 -1
- data/app/controllers/error_response_controller.rb +4 -0
- data/lib/rails_exception_handler.rb +2 -7
- data/lib/rails_exception_handler/engine.rb +4 -0
- data/lib/rails_exception_handler/handler.rb +13 -1
- data/lib/rails_exception_handler/parser.rb +1 -5
- data/rails_exception_handler.gemspec +3 -2
- metadata +3 -2
data/HISTORY
CHANGED
@@ -1,15 +1,19 @@
|
|
1
1
|
CHANGELOG
|
2
2
|
|
3
3
|
|
4
|
-
v1.1.
|
4
|
+
v1.1.2 - July 19th 2011
|
5
|
+
- It should now be able to store user_info on routing errors too
|
6
|
+
- The RailsExceptionHandler class have been turned into a rails engine so that the load path manipulation could be removed
|
7
|
+
|
8
|
+
v1.1.1 - July 18th 2011
|
5
9
|
- Fixed issue related to the handling of routing errors
|
6
10
|
|
7
|
-
v1.1.0 -
|
11
|
+
v1.1.0 - July 18th 2011
|
8
12
|
- Better handling of ajax requests
|
9
13
|
- Exceptions can be mapped to specific responses
|
10
14
|
|
11
|
-
v1.0.1 -
|
15
|
+
v1.0.1 - July 17th 2011
|
12
16
|
- Minor fix for 1.8.7 compatibility
|
13
17
|
|
14
|
-
v1.0.0 -
|
18
|
+
v1.0.0 - July 17th 2011
|
15
19
|
- Initial release
|
data/README.markdown
CHANGED
@@ -82,7 +82,7 @@ config.store_user_info = {:method => :current_user, :field => :login}
|
|
82
82
|
```
|
83
83
|
|
84
84
|
Default value: false (no info will be stored)
|
85
|
-
If you turn this on and the error is generated by a client that is not logged in, then "Anonymous" will be used.
|
85
|
+
If you turn this on and the error is generated by a client that is not logged in, then "Anonymous" will be used.
|
86
86
|
|
87
87
|
### responses and response_mapping
|
88
88
|
|
@@ -92,13 +92,15 @@ Create a set of responses and then map specific exceptions to these responses. T
|
|
92
92
|
config.responses = {
|
93
93
|
:default => "<h1>500</h1><p>Internal server error</p>",
|
94
94
|
:not_found => "<h1>404</h1><p>Page not found</p>",
|
95
|
-
:wrong_token => "<h1>500</h1>There was a problem authenticating the submitted form. Reload the page and try again
|
95
|
+
:wrong_token => "<h1>500</h1><p>There was a problem authenticating the submitted form. Reload the page and try again.</p>",
|
96
|
+
:teapot => "<h1>418</h1><p>I'm a teapot</p>"
|
96
97
|
}
|
97
98
|
config.response_mapping = {
|
98
99
|
'ActiveRecord::RecordNotFound' => :not_found,
|
99
100
|
'ActionController:RoutingError' => :not_found,
|
100
101
|
'AbstractController::ActionNotFound' => :not_found,
|
101
|
-
'ActionController::InvalidAuthenticityToken' => :wrong_token
|
102
|
+
'ActionController::InvalidAuthenticityToken' => :wrong_token,
|
103
|
+
'Teapot::CoffeeGroundsNotSupported' => :teapot
|
102
104
|
}
|
103
105
|
```
|
104
106
|
|
data/Rakefile
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.2
|
@@ -1,4 +1,5 @@
|
|
1
1
|
class RailsExceptionHandler
|
2
|
+
|
2
3
|
def initialize(app)
|
3
4
|
@app = app
|
4
5
|
end
|
@@ -21,17 +22,11 @@ class RailsExceptionHandler
|
|
21
22
|
|
22
23
|
Rails.configuration.action_dispatch.show_exceptions = true
|
23
24
|
require File.expand_path(File.dirname(__FILE__)) + '/patch/show_exceptions.rb'
|
24
|
-
|
25
|
-
%w{ models controllers }.each do |dir|
|
26
|
-
path = File.join(File.dirname(__FILE__), '../app', dir)
|
27
|
-
$LOAD_PATH << path
|
28
|
-
ActiveSupport::Dependencies.autoload_paths << path
|
29
|
-
ActiveSupport::Dependencies.autoload_once_paths.delete(path)
|
30
|
-
end
|
31
25
|
end
|
32
26
|
end
|
33
27
|
|
34
28
|
require 'rails_exception_handler/configuration.rb'
|
35
29
|
require 'rails_exception_handler/handler.rb'
|
36
30
|
require 'rails_exception_handler/parser.rb'
|
31
|
+
require 'rails_exception_handler/engine.rb'
|
37
32
|
require 'net/http'
|
@@ -4,7 +4,18 @@ class RailsExceptionHandler::Handler
|
|
4
4
|
@env = env
|
5
5
|
@request = ActionDispatch::Request.new(@env)
|
6
6
|
@parsed_error = nil
|
7
|
-
@
|
7
|
+
if(@env['action_controller.instance'])
|
8
|
+
@controller = @env['action_controller.instance']
|
9
|
+
else
|
10
|
+
# A routing error has occurred and no controller instance exists. Here I am firing off a
|
11
|
+
# request to a dummy action that goes through the whole action dispatch stack, which will
|
12
|
+
# hopefully make sure that any authentication mechanism are properly initialized so that
|
13
|
+
# we may get the current_user object later.
|
14
|
+
@controller = ErrorResponseController.new
|
15
|
+
@controller.request = @request
|
16
|
+
@controller.response = ActionDispatch::Response.new
|
17
|
+
@controller.process(:dummy_action)
|
18
|
+
end
|
8
19
|
end
|
9
20
|
|
10
21
|
def handle_exception
|
@@ -75,3 +86,4 @@ class RailsExceptionHandler::Handler
|
|
75
86
|
return config.responses[key]
|
76
87
|
end
|
77
88
|
end
|
89
|
+
|
@@ -49,11 +49,7 @@ class RailsExceptionHandler::Parser
|
|
49
49
|
def user_info
|
50
50
|
config = RailsExceptionHandler.configuration.store_user_info
|
51
51
|
return nil unless(config)
|
52
|
-
|
53
|
-
user_object = @controller.send(config[:method])
|
54
|
-
rescue
|
55
|
-
user_object = nil
|
56
|
-
end
|
52
|
+
user_object = @controller.send(config[:method])
|
57
53
|
user_object ? user_object.send(config[:field]) : 'Anonymous'
|
58
54
|
end
|
59
55
|
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{rails_exception_handler}
|
8
|
-
s.version = "1.1.
|
8
|
+
s.version = "1.1.2"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Sharagoz"]
|
12
|
-
s.date = %q{2011-07-
|
12
|
+
s.date = %q{2011-07-19}
|
13
13
|
s.description = %q{}
|
14
14
|
s.email = %q{contact@sharagoz.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -29,6 +29,7 @@ Gem::Specification.new do |s|
|
|
29
29
|
"lib/patch/show_exceptions.rb",
|
30
30
|
"lib/rails_exception_handler.rb",
|
31
31
|
"lib/rails_exception_handler/configuration.rb",
|
32
|
+
"lib/rails_exception_handler/engine.rb",
|
32
33
|
"lib/rails_exception_handler/handler.rb",
|
33
34
|
"lib/rails_exception_handler/parser.rb",
|
34
35
|
"rails_exception_handler.gemspec",
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rails_exception_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 1.1.
|
5
|
+
version: 1.1.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Sharagoz
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-07-
|
13
|
+
date: 2011-07-19 00:00:00 +02:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/patch/show_exceptions.rb
|
91
91
|
- lib/rails_exception_handler.rb
|
92
92
|
- lib/rails_exception_handler/configuration.rb
|
93
|
+
- lib/rails_exception_handler/engine.rb
|
93
94
|
- lib/rails_exception_handler/handler.rb
|
94
95
|
- lib/rails_exception_handler/parser.rb
|
95
96
|
- rails_exception_handler.gemspec
|