try {
if ($user_session_object['device_type'] == '1') {
$this->sendNotificationAndroidOne($notificationData);
}
throw new Exception("newInner");
//throw new Exception("newInner");
if ($user_session_object['device_type'] == '2') {
$this->sendNotificationIphone($notificationData);
}
}catch(Exception $ex){
echo 'Exception occur while send push notification';
exit;
}
获取错误:异常'在文件中找不到。提前致谢
答案 0 :(得分:4)
这可能是命名空间问题(与Zend Framework无关),因此您需要throw new \Exception("newInner");
和catch(\Exception $ex)
。
否则,请在您的问题中添加完整的错误消息。
答案 1 :(得分:2)
根据您的代码" throw new Exception("newInner")
"它没有在try{}
块内部产生任何意义,因为无论何时发现异常,都会调用catch(){}
块。
您应该使用下面的try---catch
。
try{
if ($user_session_object['device_type'] == '1') {
$this->sendNotificationAndroidOne($notificationData);
}
if ($user_session_object['device_type'] == '2') {
$this->sendNotificationIphone($notificationData);
}
}catch (\Exception $e) {
var_dump($e->getMessage());
var_dump($e->getCode());
exit;
}