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

Exceptions in #before block are not caught by error handler #812

Closed
Wardrop opened this Issue Mar 27, 2012 · 5 comments

Comments

Projects
None yet
4 participants
@Wardrop

Wardrop commented Mar 27, 2012

I've noticed in Padrino 0.10.5 that exceptions raised from a #before block do not invoke the user-defined error handlers, e.g.

before do
  raise StandardError, "Something went wrong"
end

error do
  "Sorry, but your request could not be fulfilled"
end

I attempted to upgrade to 0.10.6 to see if the problem still exists, however my application completely broke, that's a separate issue though, so I'll have to assume the behavior is unchanged in 0.10.6 unless someone can prove otherwise.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Mar 27, 2012

Member

can you elaborate on 'my app completely broke'. Are you using pry?

Member

nesquena commented Mar 27, 2012

can you elaborate on 'my app completely broke'. Are you using pry?

@Wardrop

This comment has been minimized.

Show comment
Hide comment
@Wardrop

Wardrop Mar 27, 2012

My configure blocks were being executed before any of dependencies (models, library file) were loaded. 0.10.5 loaded everything before the configure blocks were run, after all the whole point of a configure block is to configure the application environment which includes application dependencies.

Anyway I'm more concerned about the issue with before block errors not being caught. Something else I've noticed is that if a route raises an exception, before blocks are called again. So they're called once at the start of the request, and then called again whenever an error occurs. This may be part of the same issue as this doesn't seem like the intended behavior.

Wardrop commented Mar 27, 2012

My configure blocks were being executed before any of dependencies (models, library file) were loaded. 0.10.5 loaded everything before the configure blocks were run, after all the whole point of a configure block is to configure the application environment which includes application dependencies.

Anyway I'm more concerned about the issue with before block errors not being caught. Something else I've noticed is that if a route raises an exception, before blocks are called again. So they're called once at the start of the request, and then called again whenever an error occurs. This may be part of the same issue as this doesn't seem like the intended behavior.

@nesquena

This comment has been minimized.

Show comment
Hide comment
@nesquena

nesquena Mar 27, 2012

Member

OK thanks for the report. We will investigate soon.

Member

nesquena commented Mar 27, 2012

OK thanks for the report. We will investigate soon.

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Jan 10, 2013

Member

The second part of the issue is related to #818

Member

ujifgc commented Jan 10, 2013

The second part of the issue is related to #818

ujifgc added a commit to ujifgc/padrino-framework that referenced this issue Jan 10, 2013

@ujifgc

This comment has been minimized.

Show comment
Hide comment
@ujifgc

ujifgc Jan 10, 2013

Member

@Wardrop the error do part should be error 500 do in your code to customize StandardError or other common exceptions.

Member

ujifgc commented Jan 10, 2013

@Wardrop the error do part should be error 500 do in your code to customize StandardError or other common exceptions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment