Yet Another Framework Yaf_Dispatcher::catchException

(Yaf >=1.0.0)

Yaf_Dispatcher::catchException — 예외 포착 켜기/끄기


설명

public Yaf_Dispatcher::catchException(bool $flag = ?): Yaf_Dispatcher

application.dispatcher.throwException이 On(Yaf_Dispatcher::throwException(TRUE)()을 호출하여 활성화할 수도 있습니다.)인 동안 Yaf는 트리거 오류 대신 오류가 발생하면 예외를 throw합니다.

그런 다음 Yaf_Dispatcher::catchException()(set application.dispatcher.catchException으로도 활성화할 수 있음)을 활성화하면 포착되지 않은 모든 예외가 정의된 경우 ErrorController::error에 의해 포착됩니다.


매개변수

flag
bool

반환 값


Examples

예제 #1 Yaf_Dispatcher::catchException() 예제

                  
/* if you defined a ErrorController like following */
<?php
class ErrorController extends Yaf_Controller_Abstract {
     /**
      * you can also call to Yaf_Request_Abstract::getException to get the
      * un-caught exception.
      */
     public function errorAction($exception) {
        /* error occurs */
        switch ($exception->getCode()) {
            case YAF_ERR_NOTFOUND_MODULE:
            case YAF_ERR_NOTFOUND_CONTROLLER:
            case YAF_ERR_NOTFOUND_ACTION:
            case YAF_ERR_NOTFOUND_VIEW:
                echo 404, ":", $exception->getMessage();
                break;
            default :
                $message = $exception->getMessage();
                echo 0, ":", $exception->getMessage();
                break;
        }
     }
}
?>
                  
                

위의 예는 다음과 유사한 결과를 출력합니다.

/* now if some error occur, assuming access a non-exists controller(or you can throw a exception yourself): */
404:Could not find controller script **/application/controllers/No-exists-controller.php
                

기타