Send Notifications for Exceptions with the Notifiable Exception Package

Send Notifications for Exceptions with the Notifiable Exception Package

Notifiable Exception is a Laravel package by Andrea Marco Sartori to send notifications for certain exceptions. For exceptions to be notifiable, they need to implement the package’s Notifiable interface and use the Notifies trait. Here’s an example from the project’s readme:

use Cerbero\NotifiableException\Notifiable;
use Cerbero\NotifiableException\Notifies;
use Exception;

class UrgentException extends Exception implements Notifiable
{
    use Notifies;
}

You can also extend the NotifiableException class from the package if you don’t need to extend any particular exception class.

If you don’t catch notifiable exceptions they will be notified automatically. However, you can have granular control when using a try/catch:

try {
    $this->someCallThatThrowsAnException();
} catch (NotifiableException $e) {
    $e->notify();
    // exception handling logic
}

This package is capable of other interesting things like customizing the notification channels for a specific exception class and customizing the message per channel. Check out the package’s README.md for full details.

You can learn more about this package, get full installation instructions, and view the source code on GitHub at cerbero90/notifiable-exception.


Filed in: News / packages


Newsletter

Join the weekly newsletter and never miss out on new tips, tutorials, and more.

Laravel News Partners

Laravel Jobs

PHP Data Engineer
Remote (US)
FBS
Software Developer
Remote (US & Canada)
Alley
Backend Software Engineer
Remote (UTC +/- 5)
Smartbnb
Programmer
Remote (Overlap w/ Continental US Time Zones)
Tighten
Senior Backend Engineer
Remote
64 Robots
Senior Laravel Developer
Atlanta, GA
Helium LLC
Full-Stack Developer (JS - Vue.js, PHP - Laravel)
US Remote / Telecommute
TTEC Digital