Skip to content

Commit 026ef1e

Browse files
committed
Add chatIdNotProvided() exception.
1 parent 667b493 commit 026ef1e

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

src/Exceptions/CouldNotSendNotification.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,14 @@ public static function couldNotCommunicateWithTelegram()
4747
{
4848
return new static('The communication with Telegram failed.');
4949
}
50+
51+
/**
52+
* Thrown when there is no chat id provided.
53+
*
54+
* @return static
55+
*/
56+
public static function chatIdNotProvided()
57+
{
58+
return new static('Telegram notification chat ID was not provided. Please refer usage docs.');
59+
}
5060
}

src/TelegramChannel.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
use Illuminate\Notifications\Notification;
66
use NotificationChannels\Telegram\Events\MessageWasSent;
77
use NotificationChannels\Telegram\Events\SendingMessage;
8+
use NotificationChannels\Telegram\Exceptions\CouldNotSendNotification;
89

910
class TelegramChannel
1011
{
@@ -43,7 +44,7 @@ public function send($notifiable, Notification $notification)
4344

4445
if ($message->toNotGiven()) {
4546
if (!$to = $notifiable->routeNotificationFor('telegram')) {
46-
return;
47+
throw CouldNotSendNotification::chatIdNotProvided();
4748
}
4849

4950
$message->to($to);

0 commit comments

Comments
 (0)