Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

error do ... end doesn't seem to work for a default error handler #647

Closed
udzura opened this issue Aug 30, 2011 · 2 comments
Closed

error do ... end doesn't seem to work for a default error handler #647

udzura opened this issue Aug 30, 2011 · 2 comments

Comments

@udzura
Copy link
Contributor

udzura commented Aug 30, 2011

Dear Team,

I tryed to catch all exceptions by error do ... end block, but I found the code like below:

class App < Padrino::Application
  #...
  configure :production do
    error ::Exception do
      Padrino.logger.error "Catching #{env['sinatra.error'].class}."
      # some logging...
      erb :'errors/500'
    end
  end
end

doesn't work on production.

I guess this is because the error ::Exception do ... end block is overrided by Padrino::Application.default_errors!

https://github.com/padrino/padrino-framework/blob/master/padrino-core/lib/padrino-core/application.rb#L212

And for example, this code works.

class App < Padrino::Application
  #...
  def self.default_errors!
    configure :production do
      error ::Exception do
        Padrino.logger.error "Catching #{env['sinatra.error'].class}."
        # some logging...
        erb :'errors/500'
      end
    end
  end
end

I hope Padrino::Application.default_errors! won't override the "::Exception" error block when error Exception do is already declared.

Thank you,
Uchio Kondo

@DAddYE
Copy link
Member

DAddYE commented Aug 30, 2011

@udzura try with this:

error 500 do
  ...

@DAddYE DAddYE closed this as completed in 8daec1d Aug 30, 2011
@udzura
Copy link
Contributor Author

udzura commented Aug 31, 2011

Thanks for advise, and an elegant commit!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants