1

我试图在 cakephp 中创建一个新的自定义处理程序。它不适合我。当用户尝试访问他无法访问/限制的 url 时,我需要向用户显示自定义消息。现在蛋糕显示内部服务器错误,但我需要使用他的可访问页面链接显示自定义消息。我需要在 /Lib/...php 中抛出异常

先感谢您。

4

1 回答 1

2

You can create a custom exception handler in cakephp 2.x see this link

http://book.cakephp.org/2.0/en/development/exceptions.html#create-your-own-exception-handler-with-exception-handler

http://book.cakephp.org/2.0/en/development/exceptions.html#using-a-custom-renderer-with-exception-renderer-to-handle-application-exceptions

You can change layout in beforeRender() of AppController

public function beforeRender(){
  if($this->name == 'CakeError'){
      $this->layout = 'error';
   }        
}
于 2013-10-09T09:34:14.137 回答