Skip to content

Commit

Permalink
Add recipientNotProvided() exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
irazasyed committed Aug 15, 2016
1 parent b935a0d commit 4818bb8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
10 changes: 10 additions & 0 deletions src/Exceptions/CouldNotSendNotification.php
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,14 @@ public static function messageButtonsLimitExceeded()
{
return new static('You cannot add more than 3 buttons in 1 notification message.');
}

/**
* Thrown when there is no user id or phone number provided.
*
* @return static
*/
public static function recipientNotProvided()
{
return new static('Facebook notification recipient ID or Phone Number was not provided. Please refer usage docs.');
}
}
3 changes: 2 additions & 1 deletion src/FacebookChannel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
use NotificationChannels\Facebook\Events\MessageWasSent;
use NotificationChannels\Facebook\Events\SendingMessage;
use Illuminate\Notifications\Notification;
use NotificationChannels\Facebook\Exceptions\CouldNotSendNotification;

class FacebookChannel
{
Expand Down Expand Up @@ -40,7 +41,7 @@ public function send($notifiable, Notification $notification)

if ($message->toNotGiven()) {
if (! $to = $notifiable->routeNotificationFor('facebook')) {
return;
throw CouldNotSendNotification::recipientNotProvided();
}

$message->to($to);
Expand Down

0 comments on commit 4818bb8

Please sign in to comment.