(Yaf >=1.0.0)
Yaf_Dispatcher::catchException — 锟斤拷锟斤拷/锟截憋拷锟皆讹拷锟届常锟斤拷锟斤拷锟斤拷
锟斤拷 application.dispatcher.throwException 锟斤拷锟斤拷锟斤拷时锟斤拷锟斤拷也锟斤拷锟斤拷通锟斤拷锟斤拷锟斤拷 Yaf_Dispatcher::throwException(TRUE)() 锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷Yaf锟斤拷锟斤拷锟阶筹拷锟届常锟斤拷锟斤拷锟角达拷锟斤拷锟届常锟斤拷锟斤拷锟斤拷
锟斤拷锟斤拷锟斤拷锟斤拷锟� Yaf_Dispatcher::catchException() 锟斤拷锟斤拷锟斤拷通锟斤拷锟斤拷锟斤拷application.dispatcher.catchException锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟斤拷锟姐定锟斤拷锟斤拷锟届常锟斤拷锟斤拷锟絚ontroller锟斤拷锟斤拷锟斤拷拢锟結af锟结将锟斤拷锟斤拷未锟斤拷锟斤拷锟斤拷斐o拷锟斤拷锟紼rror Controller锟斤拷Error Action锟斤拷锟斤拷锟斤拷
flag
bool
Example #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 error($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