我的应用程序在用户注册时发送一条短信。如果数字无效,并且Twilio无法发送该异常,我将尝试处理该异常。但是,当消息失败时,它似乎永远不会到达try / catch子句中的陷阱。
try {
$message = $twilio->messages
->create(
"$user->phone", // to
array("from" => "$siteNumber", "body" => "$message_text")
);
} catch (TwilioException $e) {
return $e->getMessage();
}
我还尝试了以下捕获条件。
} catch (\Services_Twilio_RestException $e) {
return $e->getMessage();
}
catch (RestException $e) {
return redirect()->back()->withFlashSuccess("Failed To Send Text");
}
答案 0 :(得分:1)
请尝试更改捕获异常
catch (\Exception $e) {
return $e->getMessage();
}
它对我有用