Yaf_Dispatcher::catchException
(Yaf >=1.0.0)
Yaf_Dispatcher::catchException — Switch on/off exception catching
Описание
While the application.dispatcher.throwException is On(you can also calling to Yaf_Dispatcher::throwException(TRUE)() to enable it), Yaf will throw Exception whe error occurrs instead of trigger error.
then if you enable Yaf_Dispatcher::catchException()(also can enabled by set application.dispatcher.catchException), all uncaught Exceptions will be caught by ErrorController::error if you have defined one.
Список параметров
-
flag
-
bool
Возвращаемые значения
Примеры
Пример #1 Yaf_Dispatcher::catchException()example
/* 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
Смотрите также
- Yaf_Dispatcher::throwException() - Switch on/off exception throwing
- Yaf_Dispatcher::setErrorHandler() - Set error handler
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Другие базовые расширения
- Yet Another Framework
- Функция Yaf_Dispatcher::autoRender() - Switch on/off autorendering
- Функция Yaf_Dispatcher::catchException() - Switch on/off exception catching
- Функция Yaf_Dispatcher::__clone() - Yaf_Dispatcher can not be cloned
- Функция Yaf_Dispatcher::__construct() - Yaf_Dispatcher constructor
- Функция Yaf_Dispatcher::disableView() - Disable view rendering
- Функция Yaf_Dispatcher::dispatch() - Dispatch a request
- Функция Yaf_Dispatcher::enableView() - enable view rendering
- Функция Yaf_Dispatcher::flushInstantly() - Switch on/off the instant flushing
- Функция Yaf_Dispatcher::getApplication() - Retrive the application
- Функция Yaf_Dispatcher::getInstance() - Retrive the dispatcher instance
- Функция Yaf_Dispatcher::getRequest() - Retrive the request instance
- Функция Yaf_Dispatcher::getRouter() - Retrive router instance
- Функция Yaf_Dispatcher::initView() - Initialize view and return it
- Функция Yaf_Dispatcher::registerPlugin() - Register a plugin
- Функция Yaf_Dispatcher::returnResponse() - The returnResponse purpose
- Функция Yaf_Dispatcher::setDefaultAction() - Change default action name
- Функция Yaf_Dispatcher::setDefaultController() - Change default controller name
- Функция Yaf_Dispatcher::setDefaultModule() - Change default module name
- Функция Yaf_Dispatcher::setErrorHandler() - Set error handler
- Функция Yaf_Dispatcher::setRequest() - The setRequest purpose
- Функция Yaf_Dispatcher::setView() - Set a custom view engine
- Функция Yaf_Dispatcher::__sleep() - Yaf_Dispatcher can not be serialized
- Функция Yaf_Dispatcher::throwException() - Switch on/off exception throwing
- Функция Yaf_Dispatcher::__wakeup() - Yaf_Dispatcher can not be unserialized
Коментарии
404 Not Found