rails_exception_handler 1.1.0 → 1.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +3 -0
- data/README.markdown +6 -6
- data/VERSION +1 -1
- data/lib/rails_exception_handler/handler.rb +1 -10
- data/lib/rails_exception_handler/parser.rb +5 -1
- data/rails_exception_handler.gemspec +1 -1
- metadata +1 -1
data/HISTORY
CHANGED
data/README.markdown
CHANGED
@@ -30,13 +30,13 @@ RailsExceptionHandler.configure do |config|
|
|
30
30
|
# {:target_url_regxp => /\b(myphpadmin)\b/i}
|
31
31
|
# ]
|
32
32
|
# config.responses = { # There must be a default response. The rest is up to you.
|
33
|
-
# :default => "<h1>500</h1><p>Internal server error</p>"
|
34
|
-
# :custom => "<h1>404</h1><p>Page not found</p>"
|
33
|
+
# :default => "<h1>500</h1><p>Internal server error</p>",
|
34
|
+
# :custom => "<h1>404</h1><p>Page not found</p>"
|
35
35
|
# }
|
36
36
|
# config.response_mapping = { # All errors are mapped to the :default response unless overridden here
|
37
|
-
# 'ActiveRecord::RecordNotFound' => :
|
38
|
-
# 'ActionController
|
39
|
-
# 'AbstractController::ActionNotFound' => :
|
37
|
+
# 'ActiveRecord::RecordNotFound' => :custom,
|
38
|
+
# 'ActionController::RoutingError' => :custom,
|
39
|
+
# 'AbstractController::ActionNotFound' => :custom
|
40
40
|
# }
|
41
41
|
end
|
42
42
|
```
|
@@ -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. Currently, "Anonymous" is always used on routing errors, regardless of whether the user is logged in or not. This because the error happens before a controller instance has been initialized, and I haven't found a safe way to do this manually yet.
|
86
86
|
|
87
87
|
### responses and response_mapping
|
88
88
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.1.
|
1
|
+
1.1.1
|
@@ -4,16 +4,7 @@ class RailsExceptionHandler::Handler
|
|
4
4
|
@env = env
|
5
5
|
@request = ActionDispatch::Request.new(@env)
|
6
6
|
@parsed_error = nil
|
7
|
-
|
8
|
-
@controller = @env['action_controller.instance']
|
9
|
-
else
|
10
|
-
# During routing errors a controller object must be created manually and the before filters run,
|
11
|
-
# in case they are used to set up the authentication mechanism that provides the current_user object
|
12
|
-
@controller = ApplicationController.new
|
13
|
-
@controller.request = @request
|
14
|
-
filters = @controller._process_action_callbacks.collect {|cb| cb.filter if(cb.kind == :before)}
|
15
|
-
filters.each { |filter| @controller.send(filter) }
|
16
|
-
end
|
7
|
+
@controller = @env['action_controller.instance'] || ApplicationController.new
|
17
8
|
end
|
18
9
|
|
19
10
|
def handle_exception
|
@@ -49,7 +49,11 @@ class RailsExceptionHandler::Parser
|
|
49
49
|
def user_info
|
50
50
|
config = RailsExceptionHandler.configuration.store_user_info
|
51
51
|
return nil unless(config)
|
52
|
-
|
52
|
+
begin
|
53
|
+
user_object = @controller.send(config[:method])
|
54
|
+
rescue
|
55
|
+
user_object = nil
|
56
|
+
end
|
53
57
|
user_object ? user_object.send(config[:field]) : 'Anonymous'
|
54
58
|
end
|
55
59
|
|