GithubHelp home page GithubHelp logo

Comments (7)

jaredhoward avatar jaredhoward commented on May 28, 2024

This is actually my issue; I accidentally used the wrong account to start this issue.

Looking into this a little farther, I'm noticing that ActiveRecord::RecordNotFound hasn't been defined by the time ExceptionNotifier is loaded. So ActiveRecord::RecordNotFound isn't added to the ignore list.

If I add this to my environment file (like config/environments/development.rb as I'm testing it):

config.middleware.use ExceptionNotifier,
:ignore_exceptions => [ActiveRecord::RecordNotFound]

I get this error:

uninitialized constant ActiveRecord::RecordNotFound (NameError)

So I'd assume that ActiveRecord isn't loaded at this point.

from exception_notification.

smartinez87 avatar smartinez87 commented on May 28, 2024

can you provide a failing test reproducing this bug? Thanks!

from exception_notification.

jaredhoward avatar jaredhoward commented on May 28, 2024

Not exactly sure what you're asking for. I'll write everything that I'm doing to use ExceptionNotification.

Ruby 1.9.2
Rails 3.0.5
ExceptionNotification gem 2.5.2

Gemfile:

gem 'exception_notification'

config/environments/development.rb:

SHD::Application.config.middleware.use ExceptionNotifier,
  :ignore_exceptions => [ActiveRecord::RecordNotFound]

explicitly call ActiveRecord::RecordNotFound to force it to be loaded.

Now when starting the server, I git this:

Macintosh-4:shd jhoward$ rails server
=> Booting WEBrick
=> Rails 3.0.5 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
Exiting
/Volumes/code/shd/config/environments/development.rb:28:in `<top (required)>': uninitialized constant ActiveRecord::RecordNotFound (NameError)
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/application/bootstrap.rb:11:in `block in <module:Bootstrap>'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `instance_exec'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:25:in `run'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:50:in `block in run_initializers'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `each'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/initializable.rb:49:in `run_initializers'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/application.rb:134:in `initialize!'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/application.rb:77:in `method_missing'
        from /Volumes/code/shd/config/environment.rb:5:in `<top (required)>'
        from /Volumes/code/shd/config.ru:3:in `block in <main>'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.4/lib/rack/builder.rb:46:in `instance_eval'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.4/lib/rack/builder.rb:46:in `initialize'
        from /Volumes/code/shd/config.ru:1:in `new'
        from /Volumes/code/shd/config.ru:1:in `<main>'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.4/lib/rack/builder.rb:35:in `eval'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.4/lib/rack/builder.rb:35:in `parse_file'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.4/lib/rack/server.rb:162:in `app'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.4/lib/rack/server.rb:253:in `wrapped_app'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/rack-1.2.4/lib/rack/server.rb:204:in `start'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands/server.rb:65:in `start'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands.rb:30:in `block in <top (required)>'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands.rb:27:in `tap'
        from /Users/jhoward/.rvm/gems/ruby-1.9.2-p180/gems/railties-3.0.5/lib/rails/commands.rb:27:in `<top (required)>'
        from script/rails:6:in `require'
        from script/rails:6:in `<main>'

Please let me know if this isn't what you're looking for.

from exception_notification.

smartinez87 avatar smartinez87 commented on May 28, 2024

Try placing the SHD::Application.config.middleware.use ExceptionNotifier lines of configuration on the config.ru file, as explained in the README, and let me know if this fixes your issue.

from exception_notification.

jaredhoward avatar jaredhoward commented on May 28, 2024

When removing the ExceptionNotifier lines from the environment file and putting them in the config.ru so it now looks like this:

require ::File.expand_path('../config/environment',  __FILE__)
run SHD::Application

SHD::Application.config.middleware.use ExceptionNotifier,
  :ignore_exceptions => [ActiveRecord::RecordNotFound]

The application seems to not even use ExceptionNotification. The server will start up, however, no notifications are made for exceptions. Like if I just create a RuntimeError in a controller by raise "AHHHH". (ExceptionNotification does run for this exception if it's configured in the environment file.)

from exception_notification.

jaredhoward avatar jaredhoward commented on May 28, 2024

If I have the ExceptionNotifier lines of code in the application.rb file, it responds the same as if it was in the environment file in that the server boot fails with uninitialized constant error.

from exception_notification.

jaredhoward avatar jaredhoward commented on May 28, 2024

Okay, so this is how I was finally able to fix this. I decided to use an initializer to config ExceptionNotifier. So in config/initializers/exception_notification.rb, I have this:

if Rails.env.production?
  require 'active_record/errors'

  SHD::Application.config.middleware.use ExceptionNotifier,
    .........config stuff here
end

You can see that I had to require the active_record/errors file first to insure that ActiveRecord::RecordNotFound was initialized.

from exception_notification.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.