php - Force all errors to a custom error page in CakePHP -


i'm trying force of errors single custom page in cakephp(2.0) of tutorials find specific error codes. want show single error page first did point of errors of specific error status single error page. after further testing, noticed other codes not being captured.

i need code capture of http error codes single error page.

this code:

configure::write('exception', array(     'handler' => 'errorhandler::handleexception',     'renderer' => 'appexceptionrenderer',     'log' => true )); 

and appexceptionrenderer:

<?php   app::uses('exceptionrenderer', 'error');  class appexceptionrenderer extends exceptionrenderer {  public function internalerror($error) { $this->controller->beforefilter(); $this->controller->set('title_for_layout', 'internal server error'); $this->controller->render('/errors/error500'); $this->controller->response->send();  ... other error handlers similar this, limited since there lot of client , server errors  } ?> 

my template pages seems working fine, did not include it.

how alter code cover every http status code instead? or not possible?

you have override following methods:

exceptionrenderer::error400($error)  exceptionrenderer::error500($error)  

alternatively, can override exceptionrenderer:_outputmessage($template) like:

protected function _outputmessage($template) {     $this->controller->layout = 'my_error';     parent::_outputmessage($template); } 

and add file /app/view/layouts/my_error.ctp new custom layout.


Comments

Popular posts from this blog

java - Date formats difference between yyyy-MM-dd'T'HH:mm:ss and yyyy-MM-dd'T'HH:mm:ssXXX -

c# - Get rid of xmlns attribute when adding node to existing xml -