bjorntrondsen / rails_exception_handler Goto Github PK
View Code? Open in Web Editor NEWException handling for Ruby on Rails
License: MIT License
Exception handling for Ruby on Rails
License: MIT License
Hello Bjorn,
I meet some problems with ErrorResponseController.
Currently, I am trying to figure out how to resolve this problems in scope of gem. What do you think about it?
[2012-06-09 19:44:25] ERROR ActiveModel::MassAssignmentSecurity::Error: Can't mass-assign protected attributes: target_url, referer_url, params, user_agent, class_name, message, trace, doc_root, app_name, created_at, user_info
/Users/dan/.rvm/gems/ruby-1.9.2-p290/gems/activemodel-3.2.3/lib/active_model/mass_assignment_security/sanitizer.rb:48:in `process_removed_attributes'
Immidiatelly after install in development mode I meet with this problems;
Rails 3.2.3
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin10.8.0]
Is it possible to store an exception that has been handled in a begin/rescue block? For example:
begin
do_something_that_raises_an_exception
rescue => e
RailsExceptionHandler::Handler.new(Rails.env, e).handle_exception
end
I tried calling handle_exception above and received this exception:
LoadError (Unable to autoload constant ErrorResponseController, expected /var/lib/gems/2.3.0/gems/rails_exception_handler-2.3.4/app/controllers/error_response_controller.rb to define it):
WARNING: #<ArgumentError: Illformed requirement ["#<Syck::DefaultKey:0xa94393c> 3.0.12"]>
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{rails_exception_handler}
s.version = "1.4.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Sharagoz"]
s.date = %q{2012-03-10}
s.description = %q{}
s.email = %q{[email protected]}
s.extra_rdoc_files = ["README.markdown"]
s.files = [".travis.yml", "Gemfile", "Gemfile.lock", "HISTORY", "LICENCE", "README.markdown", "Rakefile", "VERSION", "app/controllers/error_response_controller.rb", "app/models/error_message.rb", "lib/patch/show_exceptions.rb", "lib/rails_exception_handler.rb", "lib/rails_exception_handler/configuration.rb", "lib/rails_exception_handler/engine.rb", "lib/rails_exception_handler/handler.rb", "lib/rails_exception_handler/parser.rb", "rails_exception_handler.gemspec", "spec/dummy_30/.gitignore", "spec/dummy_30/lib/tasks/.gitkeep", "spec/dummy_30/vendor/plugins/.gitkeep", "spec/dummy_32/.gitignore", "spec/dummy_32/app/mailers/.gitkeep", "spec/dummy_32/app/models/.gitkeep", "spec/dummy_32/lib/assets/.gitkeep", "spec/dummy_32/lib/tasks/.gitkeep", "spec/dummy_32/log/.gitkeep", "spec/dummy_32/vendor/assets/javascripts/.gitkeep", "spec/dummy_32/vendor/assets/stylesheets/.gitkeep", "spec/dummy_32/vendor/plugins/.gitkeep"]
s.homepage = %q{http://github.com/Sharagoz/rails_exception_handler}
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
s.summary = %q{Exception Handling for Rails 3}
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<rails>, ["#<Syck::DefaultKey:0xa94393c> 3.0.12"])
s.add_development_dependency(%q<rack-test>, ["#<Syck::DefaultKey:0xa942f8c> 0.5.7"])
s.add_development_dependency(%q<mysql2>, ["#<Syck::DefaultKey:0xa9425f0> 0.2.6"])
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
s.add_development_dependency(%q<jeweler>, [">= 0"])
s.add_development_dependency(%q<rails_exception_handler>, [">= 0"])
else
s.add_dependency(%q<rails>, ["#<Syck::DefaultKey:0xa94393c> 3.0.12"])
s.add_dependency(%q<rack-test>, ["#<Syck::DefaultKey:0xa942f8c> 0.5.7"])
s.add_dependency(%q<mysql2>, ["#<Syck::DefaultKey:0xa9425f0> 0.2.6"])
s.add_dependency(%q<rspec-rails>, [">= 0"])
s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<rails_exception_handler>, [">= 0"])
end
else
s.add_dependency(%q<rails>, ["#<Syck::DefaultKey:0xa94393c> 3.0.12"])
s.add_dependency(%q<rack-test>, ["#<Syck::DefaultKey:0xa942f8c> 0.5.7"])
s.add_dependency(%q<mysql2>, ["#<Syck::DefaultKey:0xa9425f0> 0.2.6"])
s.add_dependency(%q<rspec-rails>, [">= 0"])
s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<rails_exception_handler>, [">= 0"])
end
end
WARNING: Invalid .gemspec format in '/usr/local/lib/ruby/gems/1.9.1/specifications/rails_exception_handler-1.4.0.gemspec'
WARNING: #<ArgumentError: Illformed requirement ["#<Syck::DefaultKey:0xd02eed4> 3.0.12"]>
# -*- encoding: utf-8 -*-
Gem::Specification.new do |s|
s.name = %q{rails_exception_handler}
s.version = "1.4.0"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Sharagoz"]
s.date = %q{2012-03-10}
s.description = %q{}
s.email = %q{[email protected]}
s.extra_rdoc_files = ["README.markdown"]
s.files = [".travis.yml", "Gemfile", "Gemfile.lock", "HISTORY", "LICENCE", "README.markdown", "Rakefile", "VERSION", "app/controllers/error_response_controller.rb", "app/models/error_message.rb", "lib/patch/show_exceptions.rb", "lib/rails_exception_handler.rb", "lib/rails_exception_handler/configuration.rb", "lib/rails_exception_handler/engine.rb", "lib/rails_exception_handler/handler.rb", "lib/rails_exception_handler/parser.rb", "rails_exception_handler.gemspec", "spec/dummy_30/.gitignore", "spec/dummy_30/lib/tasks/.gitkeep", "spec/dummy_30/vendor/plugins/.gitkeep", "spec/dummy_32/.gitignore", "spec/dummy_32/app/mailers/.gitkeep", "spec/dummy_32/app/models/.gitkeep", "spec/dummy_32/lib/assets/.gitkeep", "spec/dummy_32/lib/tasks/.gitkeep", "spec/dummy_32/log/.gitkeep", "spec/dummy_32/vendor/assets/javascripts/.gitkeep", "spec/dummy_32/vendor/assets/stylesheets/.gitkeep", "spec/dummy_32/vendor/plugins/.gitkeep"]
s.homepage = %q{http://github.com/Sharagoz/rails_exception_handler}
s.licenses = ["MIT"]
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.7}
s.summary = %q{Exception Handling for Rails 3}
if s.respond_to? :specification_version then
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
s.specification_version = 3
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
s.add_development_dependency(%q<rails>, ["#<Syck::DefaultKey:0xd02eed4> 3.0.12"])
s.add_development_dependency(%q<rack-test>, ["#<Syck::DefaultKey:0xd02e3e4> 0.5.7"])
s.add_development_dependency(%q<mysql2>, ["#<Syck::DefaultKey:0xd02d818> 0.2.6"])
s.add_development_dependency(%q<rspec-rails>, [">= 0"])
s.add_development_dependency(%q<jeweler>, [">= 0"])
s.add_development_dependency(%q<rails_exception_handler>, [">= 0"])
else
s.add_dependency(%q<rails>, ["#<Syck::DefaultKey:0xd02eed4> 3.0.12"])
s.add_dependency(%q<rack-test>, ["#<Syck::DefaultKey:0xd02e3e4> 0.5.7"])
s.add_dependency(%q<mysql2>, ["#<Syck::DefaultKey:0xd02d818> 0.2.6"])
s.add_dependency(%q<rspec-rails>, [">= 0"])
s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<rails_exception_handler>, [">= 0"])
end
else
s.add_dependency(%q<rails>, ["#<Syck::DefaultKey:0xd02eed4> 3.0.12"])
s.add_dependency(%q<rack-test>, ["#<Syck::DefaultKey:0xd02e3e4> 0.5.7"])
s.add_dependency(%q<mysql2>, ["#<Syck::DefaultKey:0xd02d818> 0.2.6"])
s.add_dependency(%q<rspec-rails>, [">= 0"])
s.add_dependency(%q<jeweler>, [">= 0"])
s.add_dependency(%q<rails_exception_handler>, [">= 0"])
end
end
WARNING: Invalid .gemspec format in '/home/deploy/.bundler/appname/ruby/1.9.1/specifications/rails_exception_handler-1.4.0.gemspec'
Could not find rails_exception_handler-1.4.0 in any of the sources
I love this gem and it works great! I have a feature request though (or maybe it's an actual bug, depending on how you see it).
Whenever an error gets sent to the ErrorResponseController, it returns the correct error page, but it doesn't return the correct status. Whether it's a 404, 500, or some other error, the status code always seems to be 200. For the purpose of alerting bots and browsers that something went wrong, the proper status code should probably be returned.
I haven't figured out a way to do this yet, or I would have submitted a patch. I would suggest changing the render call in the ErrorResponseController, but I'm not sure how to detect the current status and pass that along. (We used to explicitly call render :partial => "blah", :status => 404
but without a hard-coded status, I'm not sure how to return the correct status depending on the nature of the error.)
Hello. I suggest to add checking if(RailsExceptionHandler.configuration.activate?)
to manual exception handling in order to tests are running if RailsExceptionHandler is only for production mode.
https://github.com/Sharagoz/rails_exception_handler/wiki/Manual-exception-handling-outside-of-rack
Hi @Sharagoz,
I really like your exception notification solution, because it's offering the possibility to send the exception to a central URI. This makes handling the exceptions a lot easier than getting spamed via email.
But compared with other exception notifier, I'm only getting limited data to track down a bug. I get a whole backtrace and some information on the request params. But for example to track a bug in a load-balanced scenario, I can't figure out on which server the exception occurs.
Are there any plans to add some more detailed information, like f.e. exception notification gem (https://github.com/smartinez87/exception_notification) it is offering: request, session, environment and backtrace.
-------------------------------
Request:
-------------------------------
* URL :
* IP address:
* Parameters:
* Rails root:
-------------------------------
Session:
-------------------------------
* session id:
* data:
-------------------------------
Environment:
-------------------------------
* DOCUMENT_ROOT :
* HTTPS :
* HTTP_ACCEPT :
* HTTP_ACCEPT_CHARSET :
* HTTP_ACCEPT_ENCODING :
* HTTP_ACCEPT_LANGUAGE :
* HTTP_CONNECTION :
* HTTP_COOKIE :
* HTTP_HOST :
* HTTP_REFERER :
* HTTP_USER_AGENT :
* PASSENGER_CONNECT_PASSWORD :
* PATH_INFO :
* QUERY_STRING :
* REMOTE_ADDR :
* REMOTE_PORT :
* REQUEST_METHOD :
* REQUEST_URI :
* SCRIPT_NAME :
* SERVER_ADDR :
* SERVER_ADMIN :
* SERVER_NAME :
* SERVER_PORT :
* SERVER_PROTOCOL :
* SERVER_SOFTWARE :
* UNIQUE_ID :
* _ :
* action_controller.request.path_parameters :
* action_controller.request.query_parameters :
* action_controller.request.request_parameters:
* action_controller.rescue.request :
* action_controller.rescue.response :
* rack.errors :
* rack.input :
* rack.multiprocess :
* rack.multithread :
* rack.request.cookie_hash :
* rack.request.cookie_string :
* rack.request.query_hash :
* rack.request.query_string :
* rack.run_once :
* rack.session :
* rack.session.options :
* rack.session.record :
* rack.url_scheme :
* rack.version :
* Process:
* Server :
-------------------------------
Backtrace:
-------------------------------
[...]
You should really add a way to set default layout, not backup one..
I am trying to hook up rails_exception_handler for the first time...
Everything works great when an exception is handled when a user is logged in, but when a user is not logged, I am getting an Incomplete response received from application
exception.
Architecture:
Rails 4, Devise, CanCan
Steps to reproduce:
I think the logic to try to go through :dummy_action to get the current user is causing this...
App 7947 stderr: [ 2015-12-14 18:16:03.6012 7996/0x0000000148b678(Worker 1) utils.rb:87 ]: *** Exception ArgumentError in Rack application object (uncaught throw :warden) (process 7996, thread 0x0000000148b678(Worker 1)):
[ 2015-12-14 18:16:03.6013 7886/7faef99a0700 age/Cor/Req/Utils.cpp:96 ]: [Client 3-1] Sending 502 response: application did not send a complete response
App 7947 stderr: from /var/lib/gems/2.1.0/gems/warden-1.2.3/lib/warden/proxy.rb:128:in `throw'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/warden-1.2.3/lib/warden/proxy.rb:128:in `authenticate!'
App 7947 stderr: from /home/doug/.bundler/ruby/2.1.0/devise-5badce5e8e51/lib/devise/controllers/helpers.rb:112:in `authenticate_user!'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:424:in `block in make_lambda'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:160:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:160:in `block in halting'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `block in halting'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:229:in `block in halting'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:166:in `block in halting'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:86:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/callbacks.rb:86:in `run_callbacks'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/abstract_controller/callbacks.rb:19:in `process_action'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/action_controller/metal/rescue.rb:29:in `process_action'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/action_controller/metal/instrumentation.rb:31:in `block in process_action'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/notifications.rb:159:in `block in instrument'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/notifications/instrumenter.rb:20:in `instrument'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/notifications.rb:159:in `instrument'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/action_controller/metal/instrumentation.rb:30:in `process_action'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/action_controller/metal/params_wrapper.rb:250:in `process_action'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activerecord-4.1.8/lib/active_record/railties/controller_runtime.rb:18:in `process_action'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/abstract_controller/base.rb:136:in `process'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionview-4.1.8/lib/action_view/rendering.rb:30:in `process'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/rails_exception_handler-2.3.4/lib/rails_exception_handler/handler.rb:17:in `initialize'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/rails_exception_handler-2.3.4/lib/patch/show_exceptions.rb:7:in `new'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/rails_exception_handler-2.3.4/lib/patch/show_exceptions.rb:7:in `render_exception_with_template'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/show_exceptions.rb:35:in `rescue in call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:38:in `call_app'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:20:in `block in call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:68:in `block in tagged'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:26:in `tagged'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/tagged_logging.rb:68:in `tagged'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/railties-4.1.8/lib/rails/rack/logger.rb:20:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/quiet_assets-1.0.3/lib/quiet_assets.rb:23:in `call_with_quiet_assets'
App 7947 stderr: from /home/doug/.bundler/ruby/2.1.0/quiet_safari-b091dff4f94c/lib/quiet_safari.rb:22:in `call_with_quiet_safari'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/request_id.rb:21:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/rack-1.5.5/lib/rack/methodoverride.rb:21:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/rack-1.5.5/lib/rack/runtime.rb:17:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/activesupport-4.1.8/lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/rack-1.5.5/lib/rack/lock.rb:17:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/actionpack-4.1.8/lib/action_dispatch/middleware/static.rb:84:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/rack-1.5.5/lib/rack/sendfile.rb:112:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/railties-4.1.8/lib/rails/engine.rb:514:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/railties-4.1.8/lib/rails/application.rb:144:in `call'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/passenger-5.0.21/src/ruby_supportlib/phusion_passenger/rack/thread_handler_extension.rb:97:in `process_request'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/passenger-5.0.21/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:152:in `accept_and_process_next_request'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/passenger-5.0.21/src/ruby_supportlib/phusion_passenger/request_handler/thread_handler.rb:113:in `main_loop'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/passenger-5.0.21/src/ruby_supportlib/phusion_passenger/request_handler.rb:416:in `block (3 levels) in start_threads'
App 7947 stderr: from /var/lib/gems/2.1.0/gems/passenger-5.0.21/src/ruby_supportlib/phusion_passenger/utils.rb:113:in `block in create_thread_and_abort_on_exception'
Thanks for any help you could provide in tracking this down. The offending URL should show the user a 404 error page, instead of "Incomplete response received from application".
Thanks!
I pulled my project from a repo on a seperate computer and I could not create the database. I get ActiveRecord::NoDatabaseError: FATAL: "ACM_development" does not exist
and PG::ConnectionBad: FATAL: database "ACM_development" does not exist
.
Removing the excpetion handler gem from my gemfile and running bundle
, then running rails db:create
fixes the issue. Then I add the gem back and run rails db:migrate
.
If ever do rails db:drop db:create
I get ExceptionHandler::Error: Migration Required โ "errors" doesn't exist
. Their seems to be a circular dependency that makes so a database cannot be created when the exception handler gem is installed.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.