Fatal Error Handler

127 views
Skip to first unread message

Juan Basso

unread,
Mar 31, 2012, 8:31:18 PM3/31/12
to cakeph...@googlegroups.com
Hi guys,

I implemented a new handler to catch fatal errors.


By default it will show a page like missing something, but showing the fatal error message, with the file and line that it happened. If debug is disabled, it will show internal server error page.

What you think?


Juan Basso

euromark

unread,
Mar 31, 2012, 9:13:55 PM3/31/12
to cakeph...@googlegroups.com
+1
I like it that there will be a build in fatal error handler soon.
as of right now one would have to apply some self-coded hack to catch and log those.

I used to do it this way:

register_shutdown_function('shutdownFunction');
function shutDownFunction() { //manual logging }


José Lorenzo Rodríguez

unread,
Mar 31, 2012, 9:33:42 PM3/31/12
to cakeph...@googlegroups.com
Nice work Juan!! I think it is ready to be merged :)

Sent from my iPhone

mark_story

unread,
Apr 1, 2012, 1:57:54 PM4/1/12
to cakeph...@googlegroups.com
Great work Juan!  I added a few comments to the docs commits.  I guess I should better document the new console handler better as well. :)

-Mark

Juan Basso

unread,
Apr 1, 2012, 4:56:29 PM4/1/12
to cakeph...@googlegroups.com
Thanks! As the core.php use the same text, I also updated.

Juan Basso

Juan Basso

unread,
Apr 2, 2012, 12:08:38 AM4/2/12
to cakeph...@googlegroups.com
After talk with Mark, the code was changed. I removed the Error.fatalErrorHandler from configuration and the regular Error.handler will receive the fatal error codes as well. The handler will define what should be the behavior for this situation.

Code and doc updated.

Juan Basso

ADmad

unread,
Apr 3, 2012, 3:15:25 PM4/3/12
to cakeph...@googlegroups.com
On a related note in 2.2 I had updated ExceptionRenderer to use a separate 'error' layout instead of 'default' layout when rendering "safe" messages in case of repeated errors/exceptions 0832e18e9e refs #2682

Then recently I again updated it to always use 'error' layout instead of 'default' 3495422ac5. I wanted to get everyone's opinion if this is good or it should be reverted back to using error layout only when rendering "safe" messages in case of repeated errors.

-ADmad

majna

unread,
Apr 4, 2012, 10:12:59 AM4/4/12
to cakeph...@googlegroups.com
Assuming that NotFoundException will render "error" layout with this change in 2.2;
it is common for 404 error pages to have menus or footer like this https://github.com/blablba
so you have to duplicate code from "default" layout in "error" layout and you end up with same problem in case of repeated errors.


On Tuesday, April 3, 2012 9:15:25 PM UTC+2, ADmad wrote:
On a related note in 2.2 I had updated ExceptionRenderer to use a separate 'error' layout instead of 'default' layout when rendering "safe" messages in case of repeated errors/exceptions 0832e18e9e refs #2682

Then recently I again updated it to always use 'error' layout instead of 'default' 3495422ac5. I wanted to get everyone's opinion if this is good or it should be reverted back to using error layout only when rendering "safe" messages in case of repeated errors.

-ADmad

On Monday, April 2, 2012 9:38:38 AM UTC+5:30, Juan Basso wrote:
After talk with Mark, the code was changed. I removed the Error.fatalErrorHandler from configuration and the regular Error.handler will receive the fatal error codes as well. The handler will define what should be the behavior for this situation.

Code and doc updated.

Juan Basso

Renan Gonçalves

unread,
Apr 4, 2012, 10:47:38 AM4/4/12
to cakeph...@googlegroups.com
Good point.
Also I don't see myself in need of a different layout in case of a error, only if its a authentication/authorization error.

But if what you want is a "temporarily" error page, there is already flash.ctp for it.
--
Renan Gonçalves aka renan.saddam
Software Engineer at TrueServer B.V.
CakePHP Core Developer
Website: renangoncalves dot com
Amsterdam, The Netherlands

mark_story

unread,
Apr 4, 2012, 2:40:53 PM4/4/12
to cakeph...@googlegroups.com
ADmad:  I would think the error layout would only be used for repeat errors or errors encountered when rendering an error.  Having it used for all errors means people will put their app helpers into it.  This means that repeat errors will continue to fail fatally.

-Mark

ADmad

unread,
Apr 5, 2012, 3:13:07 PM4/5/12
to cakeph...@googlegroups.com
Ok guys I will revert the change and use error layout only in ExceptionRenderer::_outputMessageSafe() as i had initially done.

-ADmad

Ceeram

unread,
Apr 20, 2012, 3:50:31 AM4/20/12
to cakeph...@googlegroups.com
Fatal errors should also use error layout.

$helpers = array('Good', 'Bad');

when BadHelper produces fatal, the default layout will cause another error when calling method on non-object GoodHelper, which will hide the original fatal error. In the stack trace only i can see the FatalError handler is starting point, not what the original fatal error was. quick fix was adding $this->layout = 'error'; to the fatal_error.ctp view

Op donderdag 5 april 2012 21:13:07 UTC+2 schreef ADmad het volgende:

mark_story

unread,
Apr 20, 2012, 9:18:22 PM4/20/12
to cakeph...@googlegroups.com
Sounds like a good idea, do you want to make that change Ceeram?

-Mark

Ceeram

unread,
Apr 21, 2012, 4:58:48 AM4/21/12
to cakeph...@googlegroups.com

Sure, setting layout in the view file is ok?

Op 21 apr. 2012 03:18 schreef "mark_story" <mark....@gmail.com> het volgende:

Ceeram

unread,
Apr 21, 2012, 12:04:20 PM4/21/12
to cakeph...@googlegroups.com
After looking again, i see error layout is in app dir only, perhaps fatal error even use no layout to avoid other issues?

Op zaterdag 21 april 2012 10:58:48 UTC+2 schreef Ceeram het volgende:

ADmad

unread,
Apr 21, 2012, 3:39:52 PM4/21/12
to cakeph...@googlegroups.com
View class uses bake skel as fallback for files, so if you don't have error layout in your app the one from bake skel will be used.
Reply all
Reply to author
Forward
0 new messages