rails_exception_handler 1.1.2 → 1.2.0

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 CHANGED
@@ -1,6 +1,10 @@
1
1
  CHANGELOG
2
2
 
3
3
 
4
+ v1.2.0 - August 21st 2011
5
+ - Bug fixed where exception_database had to be configured even if active record storage was not chosen
6
+ - If public/500.html and/or public/400.html exists, these will be used as responses
7
+
4
8
  v1.1.2 - July 19th 2011
5
9
  - It should now be able to store user_info on routing errors too
6
10
  - The RailsExceptionHandler class have been turned into a rails engine so that the load path manipulation could be removed
data/README.markdown CHANGED
@@ -29,7 +29,7 @@ RailsExceptionHandler.configure do |config|
29
29
  # {:user_agent_regxp => /\b(ApptusBot|TurnitinBot|DotBot|SiteBot)\b/i},
30
30
  # {:target_url_regxp => /\b(myphpadmin)\b/i}
31
31
  # ]
32
- # config.responses = { # There must be a default response. The rest is up to you.
32
+ # config.responses = { # There must be a default response if public/500.html and public/400.html does not exist.
33
33
  # :default => "<h1>500</h1><p>Internal server error</p>",
34
34
  # :custom => "<h1>404</h1><p>Page not found</p>"
35
35
  # }
@@ -86,6 +86,8 @@ If you turn this on and the error is generated by a client that is not logged in
86
86
 
87
87
  ### responses and response_mapping
88
88
 
89
+ Note: public/500.html and public/400.html will be used if these exists. Remove these files before applying the configuration below.
90
+
89
91
  Create a set of responses and then map specific exceptions to these responses. There needs to be a response called :default which is used for the exceptions that are not explicity mapped to a response.
90
92
 
91
93
  ```ruby
@@ -223,3 +225,11 @@ config.storage_strategies = [:remote_url => {:target => 'http://example.com/erro
223
225
  ```
224
226
  This option is meant for those who want to store the exception in a database table, but does not have direct access to the database itself, making active record store unsuitable. You need a web app on a server that has access to the database. An HTTP POST request will be sent to the specified URL with the error message as data.
225
227
  If you use a Rails app at the other end you should simply be able to do _ErrorMessage.create(params[:error_message])_ to save the report.
228
+
229
+ ## Contributors
230
+
231
+ David Rice
232
+
233
+ ## Licence
234
+
235
+ Copyright © 2011 Bjørn Trondsen, released under the MIT license
data/VERSION CHANGED
@@ -1 +1 @@
1
- 1.1.2
1
+ 1.2.0
@@ -1,3 +1,3 @@
1
1
  class ErrorMessage < ActiveRecord::Base
2
- establish_connection(:exception_database)
2
+ establish_connection(:exception_database) if RailsExceptionHandler.configuration.active_record?
3
3
  end
@@ -8,6 +8,11 @@ class RailsExceptionHandler::Configuration
8
8
  @store_user_info = false
9
9
  @fallback_layout = 'application'
10
10
  @response_mapping = {}
11
- @responses = { :default => '<h1>Internal server error</h1><p>The application has encountered an unexpected issue.</p>' }
11
+ @responses = {}
12
12
  end
13
+
14
+ def active_record?
15
+ @storage_strategies.include?(:active_record)
16
+ end
17
+
13
18
  end
@@ -67,7 +67,15 @@ class RailsExceptionHandler::Handler
67
67
  @env['exception_handler.layout'] = response_layout
68
68
  @env['exception_handler.response'] = response_text
69
69
  response = ErrorResponseController.action(:index).call(@env)
70
- response[0] = @parsed_error.routing_error? ? 404 : 500
70
+ if @parsed_error.routing_error?
71
+ response[0] = 404
72
+ file = "#{Rails.root}/public/404.html"
73
+ response[2].body = File.read(file) if File.exists?(file)
74
+ else
75
+ response[0] = 500
76
+ file = "#{Rails.root}/public/500.html"
77
+ response[2].body = File.read(file) if File.exists?(file)
78
+ end
71
79
  return response
72
80
  end
73
81
 
@@ -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.2"
8
+ s.version = "1.2.0"
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-19}
12
+ s.date = %q{2011-08-22}
13
13
  s.description = %q{}
14
14
  s.email = %q{contact@sharagoz.com}
15
15
  s.extra_rdoc_files = [
@@ -5,7 +5,7 @@ gem 'rails', '3.0.9'
5
5
  # Bundle edge Rails instead:
6
6
  # gem 'rails', :git => 'git://github.com/rails/rails.git'
7
7
 
8
- gem 'mysql2'
8
+ gem 'mysql2', '0.2.6'
9
9
 
10
10
  # Use unicorn as the web server
11
11
  # gem 'unicorn'
@@ -39,7 +39,7 @@ GEM
39
39
  mime-types (~> 1.16)
40
40
  treetop (~> 1.4.8)
41
41
  mime-types (1.16)
42
- mysql2 (0.3.6)
42
+ mysql2 (0.2.6)
43
43
  polyglot (0.3.1)
44
44
  rack (1.2.3)
45
45
  rack-mount (0.6.14)
@@ -71,5 +71,5 @@ PLATFORMS
71
71
  ruby
72
72
 
73
73
  DEPENDENCIES
74
- mysql2
74
+ mysql2 (= 0.2.6)
75
75
  rails (= 3.0.9)
@@ -22,8 +22,8 @@ describe RailsExceptionHandler::Configuration do
22
22
  @configuration.filters.should == []
23
23
  end
24
24
 
25
- it "should set the default response" do
26
- @configuration.responses.should == {:default => '<h1>Internal server error</h1><p>The application has encountered an unexpected issue.</p>' }
25
+ it "should initialize responses to an empty hash" do
26
+ @configuration.responses.should == {}
27
27
  end
28
28
 
29
29
  it "should set the reponse_mapping to {}" do
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.2
5
+ version: 1.2.0
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-19 00:00:00 +02:00
13
+ date: 2011-08-22 00:00:00 +02:00
14
14
  default_executable:
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency