auto_error 0.0.1 → 0.0.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/app/controllers/auto_error/app_errors_controller.rb +11 -13
- data/app/controllers/auto_error/application_controller.rb +7 -9
- data/app/controllers/auto_error/errors_controller.rb +22 -24
- data/app/controllers/auto_error/main_controller.rb +4 -6
- data/lib/auto_error.rb +1 -1
- data/lib/auto_error/version.rb +1 -1
- metadata +2 -3
- data/config/initializers/fabrication.rb +0 -6
@@ -1,17 +1,15 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
before_filter :ensure_authenticated
|
1
|
+
class AutoError::AppErrorsController < AutoError::ApplicationController
|
2
|
+
before_filter :ensure_authenticated
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
4
|
+
def index
|
5
|
+
@errors = AutoError::AppError.unresolved
|
6
|
+
render json: @errors.map { |ae| AutoError::AppErrorDecorator.new(ae).as_json }
|
7
|
+
end
|
9
8
|
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
end
|
9
|
+
def destroy
|
10
|
+
@error = AutoError::AppError.find( params[:id] )
|
11
|
+
@error.resolved_at = Time.now
|
12
|
+
@error.save
|
13
|
+
render json: { ok: true }
|
16
14
|
end
|
17
15
|
end
|
@@ -1,13 +1,11 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
helper :all
|
1
|
+
class AutoError::ApplicationController < ActionController::Base
|
2
|
+
include AutoError::ApplicationHelper
|
3
|
+
helper :all
|
5
4
|
|
6
|
-
|
5
|
+
protected
|
7
6
|
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
end
|
7
|
+
def ensure_authenticated
|
8
|
+
context = AutoError::AuthContext.new(env)
|
9
|
+
raise AutoError::Errors::Denied unless AutoError::Config.auth_with.call(context)
|
12
10
|
end
|
13
11
|
end
|
@@ -1,32 +1,30 @@
|
|
1
|
-
|
2
|
-
class ErrorsController < ApplicationController
|
1
|
+
class AutoError::ErrorsController < AutoError::ApplicationController
|
3
2
|
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
3
|
+
def show
|
4
|
+
# reset action_controller.instance to the original controller
|
5
|
+
# that caused the exception
|
6
|
+
env['action_controller.instance'] = env.delete('auto_error.original_controller.instance')
|
8
7
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
@exception = env['action_dispatch.exception']
|
9
|
+
@status_code = ActionDispatch::ExceptionWrapper.new(env, @exception).status_code
|
10
|
+
@rescue_response = ActionDispatch::ExceptionWrapper.rescue_responses[@exception.class.name]
|
11
|
+
@params = env['action_dispatch.request.parameters'].symbolize_keys
|
13
12
|
|
14
|
-
|
13
|
+
@status_code = 500 unless [403, 404].include?(@status_code)
|
15
14
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
AutoError::Config.error_template_renderer.bind(self).( @status_code )
|
15
|
+
if @status_code == 500
|
16
|
+
controller = "#{@params[:controller].camelize}Controller" rescue 'N/A'
|
17
|
+
action = @params[:action] || 'N/A'
|
18
|
+
where = { controller: controller, action: action }
|
19
|
+
data = {
|
20
|
+
path: env['REQUEST_URI'],
|
21
|
+
method: env['REQUEST_METHOD'],
|
22
|
+
ip: env['REMOTE_ADDR']
|
23
|
+
}
|
24
|
+
AutoError::AppError.log!( env, @exception, where, data )
|
29
25
|
end
|
30
26
|
|
27
|
+
AutoError::Config.error_template_renderer.bind(self).( @status_code )
|
31
28
|
end
|
29
|
+
|
32
30
|
end
|
@@ -1,9 +1,7 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
before_filter :ensure_authenticated
|
1
|
+
class AutoError::MainController < AutoError::ApplicationController
|
2
|
+
before_filter :ensure_authenticated
|
4
3
|
|
5
|
-
|
6
|
-
|
7
|
-
end
|
4
|
+
def index
|
5
|
+
render layout: 'auto_error/application'
|
8
6
|
end
|
9
7
|
end
|
data/lib/auto_error.rb
CHANGED
@@ -22,7 +22,7 @@ require 'auto_error/engine'
|
|
22
22
|
|
23
23
|
module AutoError
|
24
24
|
def self.setup!( app_config )
|
25
|
-
Config.send(:set_defaults)
|
25
|
+
AutoError::Config.send(:set_defaults)
|
26
26
|
app_config.action_dispatch.rescue_responses["AutoError::Errors::Denied"] = :forbidden
|
27
27
|
app_config.action_dispatch.rescue_responses["AutoError::Errors::NotFound"] = :not_found
|
28
28
|
|
data/lib/auto_error/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: auto_error
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
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-02-
|
12
|
+
date: 2013-02-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -266,7 +266,6 @@ files:
|
|
266
266
|
- app/views/errors/500.html.erb
|
267
267
|
- app/views/layouts/auto_error/application.html.erb
|
268
268
|
- app/views/layouts/errors.html.erb
|
269
|
-
- config/initializers/fabrication.rb
|
270
269
|
- config/routes.rb
|
271
270
|
- db/migrate/20130128004546_create_auto_error_app_errors.rb
|
272
271
|
- lib/auto_error/auth_context.rb
|