nexmo 오류를 처리 할 수있는 방법, try {} catch () {}를 사용하지만 작동하지 않고이 오류가 발생했습니다. Nexmo \ Client \ Exception \ Request (29) Non White-listed Destination-rejected 이 오류를 알고 있지만 나는 그것을 처리해야합니다.
이것은 코드입니다.
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Messages\MailMessage;
use Illuminate\Notifications\Messages\NexmoMessage;
//use App\admin\Course;
class ConfirmedCourse extends Notification
{
use Queueable;
protected $course;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct($course)
{
$this->course = $course;
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return ['nexmo'];
}
public function toNexmo($notifiable)
{
try {
$message = new NexmoMessage();
$message->content($this->course)
->unicode();
return $message;
}catch (\Exception $e) {
$e->getMessage();
}
}
}
과거에 notify()
try catch에서 호출을 래핑하여이 문제를 해결했습니다 .
try {
$variableToCatch = $YourModel->notify(new ConfirmedCourse($data));
} catch (\Exception $e) {
// Do what you want here...
// Log::error('nexmo failed...');
// echo 'Caught exception: ', $e->getMessage(), "\n";
// Log::error($e->getMessage());
// dd($e->getMessage())
}
당신이 전화하는 라인을 게시하면 notify()
정확한 필요한 진술을 사용하여 업데이트 할 수 있습니다.
ConfirmedCourse
클래스 에서 try catch를 제거하고 이를 호출하는 메서드의 호출 주위에 배치합니다.
지연 알림 실패를 처리하는 방법은 다음과 같습니다.
try {
$slackNotification = $user->notify(new SlackNotification($slackData));
} catch (\Exception $e) {
Log::error('slack notification failed.');
}
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다