KO 3.3 中的新功能是 HTTP::redirect 方法,它通过抛出 HTTP_Exception_302 来工作,它会冒泡并由系统处理以进行实际的重定向。
try...catch
我的问题是:如果我在一个块中调用重定向,我怎么能在不捕获异常的情况下进行重定向?
例如:
try {
if($var === TRUE){
HTTP::redirect(URL::site($_REQUEST['redirect_uri']));
}else{
throw new Exception('Error');
}
} catch(Exception $e) {
$this->template->errors[] = $e->getMessage();
}
这不会导致重定向,因为通用异常处理程序会捕获它。我该如何避免这种情况?