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 CHANGED
@@ -1,6 +1,9 @@
1
1
  CHANGELOG
2
2
 
3
3
 
4
+ v1.1.1 - 18. Jul 2011
5
+ - Fixed issue related to the handling of routing errors
6
+
4
7
  v1.1.0 - 18. Jul 2011
5
8
  - Better handling of ajax requests
6
9
  - Exceptions can be mapped to specific responses
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' => :not_found,
38
- # 'ActionController:RoutingError' => :not_found,
39
- # 'AbstractController::ActionNotFound' => :not_found,
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.0
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
- if(@env['action_controller.instance'])
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
- user_object = @controller.send(config[:method])
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
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{rails_exception_handler}
8
- s.version = "1.1.0"
8
+ s.version = "1.1.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Sharagoz"]
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.0
5
+ version: 1.1.1
6
6
  platform: ruby
7
7
  authors:
8
8
  - Sharagoz