Notifications uses package exceptions for invalid state, missing channels, unsupported delivery, driver failures, and failed delivery results.
InvalidNotificationException is thrown when notification or recipient payloads are not valid:
- notification content is empty;
- recipient address is empty;
- metadata, data, or detail keys are invalid;
- recipient payload shape is not recognized;
- a channel-specific send has no eligible recipients.
InvalidNotificationChannelException is thrown for malformed channel names.
ChannelNotFoundException is thrown when a requested channel is not registered.
ChannelAlreadyRegisteredException is thrown by registerChannel() or ChannelRegistry::register() when a channel already exists.
UnsupportedNotificationException is thrown when a driver returns false from supports().
Unexpected driver throwables are wrapped in NotificationDriverException. Notification exceptions thrown by a driver are allowed to bubble out unchanged.
Drivers should return DeliveryResult::failed() when a provider safely processed the request and returned a failure status. Drivers should throw an exception when delivery could not be attempted safely.
Failed results are not thrown automatically. Call throwIfFailed() when the caller wants exception flow:
$result = $notifier->send($notification, 'email');
$result->throwIfFailed();For multi-channel sends:
$report = $notifier->sendToChannels($notification, ['email', 'sms']);
$report->throwIfFailed();