All packages
Campaigns for Laravel
Exceptions
The package’s exceptions live in RoundlyConsulting\Campaigns\Exceptions and extend CampaignException, a RuntimeException:
| Exception | Thrown when |
|---|---|
CampaignNotFound | findOrFail(), campaign(), start() or cancel() — and campaigns:cancel — got an unknown uuid. find() returns null instead. |
CampaignAlreadyExists | prepare() — or the builder’s prepare()/dispatch() — got a uuid another campaign already holds, live or soft-deleted. The existing campaign is left untouched. |
InvalidCampaignTransition | start() on a campaign that isn’t Pending — already sending, or ended — or one another process started first, instead of queueing every recipient twice. |
RecipientNotFound | A handle’s recipient(), markProcessed() or markFailed() got an unknown recipient or one of another campaign. |
CampaignException | Base class of the package’s exceptions. SendCampaignNotification throws it when campaigns.notification is unset — caught and recorded as a failed recipient. |
InvalidConfigurationException | A config value is present but unusable — see Configuration. From RoundlyConsulting\PackageToolkit\Exceptions; it does not extend CampaignException. |
InvalidArgumentException | ->to() got something other than a string, CampaignRecipient, Contact or HasContacts owner. |
ValueError | ->viaContactType() got a string that isn’t a ContactType value. |
use RoundlyConsulting\Campaigns\Exceptions\CampaignNotFound;
use RoundlyConsulting\Campaigns\Facades\Campaigns;
try {
Campaigns::cancel($uuid);
} catch (CampaignNotFound $e) {
report($e); // "No campaign found for uuid [...]."
}Delivery errors never surface as exceptions: the recipient jobs catch them and record them on the recipient, where errorOccured and errorMessage tell you what went wrong.
Show your open-source love
This package is free and MIT-licensed. If it saves you time, a one-off donation or a Patreon membership keeps it maintained, tested and documented.
More ways to support, including cryptoBy donating, you agree to our donation terms.
Want this built into your product?
We integrate our packages into custom Laravel and AI builds. Tell us what you're working on and we'll reply within 48 hours.