We have moved our forum to GitHub Discussions. For questions about Phalcon v3/v4/v5 you can visit here and for Phalcon v6 here.

Throw exception from beforeDispatch

Hi everyone!

I cannot throw exception from beforeDispatch in Phalcon 1.3.1.
The script ends, but returns nothing. Sample application with this problem

https://bitbucket.org/demidovich/exception-bug

The file /app/plugins/Security.php has an exception, which works in version 1.2.6, but does not work in 1.3.1. Anyone know what's the matter?

Sorry for my English :)

edited Apr '14

Look at PHP log - are there any records about unhandled exception?

Try to disable view before throw exception:

$this->view->disable();

There is some specialty in Phalcon with controllers - looks like, their output is buffered and piped to views. And this is done so "hard" so it doesn't show even fatal errors - just blank pages.



978

Disabling view not helped. If it is integrated magic I'm sad. :(

Some users say that reinstalling or recompiling (depends on how do you get it) Phalcon helps - but not for me. My solution was to look for errors in PHP error log...

Additionally, didn't noticed you wrote about exception from plugin :) Can you, please, try view->disable() and throw that commented exception from your IndexController?

Hi, they apparently the behaviour in 1.3.1 was changed and exceptions are suppressed unless you catch them yourself via the beforeException event. Here is a thread with the same problem and the solution: https://github.com/phalcon/cphalcon/issues/2222