Yet Another Framework Yaf_Dispatcher::throwException
(Yaf >=1.0.0)
Yaf_Dispatcher::throwException — 예외 발생 켜기/끄기
설명
public Yaf_Dispatcher::throwException(bool $flag
= ?): Yaf_Dispatcher
예기치 않은 오류가 발생하는 동안 예외 발생을 켜거나 끕니다. 이것이 켜져 있으면 Yaf는 catch할 수 있는 오류를 트리거하는 대신 예외를 throw합니다.
같은 목적을 달성하기 위해 application.dispatcher.throwException을 사용할 수도 있습니다.
매개변수
flag
- bool
반환 값
Examples
예제 #1 Yaf_Dispatcher::throwexception() 예제
<?php
$config = array(
'application' => array(
'directory' => dirname(__FILE__),
),
);
$app = new Yaf_Application($config);
$app->getDispatcher()->throwException(true);
try {
$app->run();
} catch (Yaf_Exception $e) {
var_dump($e->getMessage());
}
?>
위의 예는 다음과 유사한 결과를 출력합니다.
string(59) "Could not find controller script /tmp/controllers/Index.php"
예제 #2 Yaf_Dispatcher::throwexception() 예제
<?php
$config = array(
'application' => array(
'directory' => dirname(__FILE__),
),
);
$app = new Yaf_Application($config);
$app->getDispatcher()->throwException(false);
$app->run();
?>
위의 예는 다음과 유사한 결과를 출력합니다.
PHP Catchable fatal error: Yaf_Application::run(): Could not find controller script /tmp/controllers/Index.php in /tmp/1.php on line 12
기타
- Yaf_Dispatcher::catchException() - 예외 포착 켜기/끄기
- Yaf_Exception