mirzabusatlic/laravel-exceptions

This package is abandoned and no longer maintained. No replacement package was suggested.

Track exceptions in a database table

This package has no released version yet, and little information is available.


README

Exception tracking for Laravel/Lumen

Installation

  1. composer require mirzabusatlic/laravel-exceptions
  2. Add Busatlic\Laravel\Exceptions\ExceptionsServiceProvider to your config/app.php.
  3. Run php artisan vendor:publish --provider=Busatlic\\Laravel\\Exceptions\\ExceptionsServiceProvider to generate the migration that will create the exceptions table
  4. Run php artisan migrate to create the exceptions table

Use

In your Exceptions\Handler.php, include the ReportsExceptions trait and then use the reportException method to report the exception like so:

namespace App\Exceptions;

use Busatlic\Laravel\Exceptions\ReportsExceptions;
use Exception;
use Illuminate\Validation\ValidationException;
use Illuminate\Auth\Access\AuthorizationException;
use Illuminate\Database\Eloquent\ModelNotFoundException;
use Symfony\Component\HttpKernel\Exception\HttpException;
use Laravel\Lumen\Exceptions\Handler as ExceptionHandler;

class Handler extends ExceptionHandler
{
    use ReportsExceptions;
    
    /**
     * A list of the exception types that should not be reported.
     *
     * @var array
     */
    protected $dontReport = [
        AuthorizationException::class,
        HttpException::class,
        ModelNotFoundException::class,
        ValidationException::class,
    ];

    /**
     * Report or log an exception.
     *
     * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
     *
     * @param  \Exception  $e
     * @return void
     */
    public function report(Exception $e)
    {
        parent::report($e);
        
        $this->reportException($e, $this->shouldReport($e));
    }

    /**
     * Render an exception into an HTTP response.
     *
     * @param  \Illuminate\Http\Request  $request
     * @param  \Exception  $e
     * @return \Illuminate\Http\Response
     */
    public function render($request, Exception $e)
    {
        return parent::render($request, $e);
    }
}