Skip to content

Commit

Permalink
55: bind a Rollbar exception handler to report exceptions to rollbar
Browse files Browse the repository at this point in the history
  • Loading branch information
ArturMoczulski committed Aug 15, 2018
1 parent 39ec203 commit b9ce5ef
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/ExceptionHandler.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

namespace Rollbar\Laravel;

use App\Exceptions\Handler as AppHandler;

class ExceptionHandler extends AppHandler
{
public function report(\Exception $exception)
{
\Rollbar\Rollbar::log(\Rollbar\Payload\Level::ERROR, $exception);

parent::report($exception);
}
}
7 changes: 7 additions & 0 deletions src/RollbarServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
use Rollbar\Laravel\MonologHandler;
use Rollbar\RollbarLogger;
use Rollbar\Rollbar;
use Illuminate\Contracts\Debug\ExceptionHandler as LaravelExceptionHandlerContract;
use Rollbar\Laravel\ExceptionHandler;

class RollbarServiceProvider extends ServiceProvider
{
Expand Down Expand Up @@ -55,6 +57,11 @@ public function register()

return $handler;
});

$this->app->bind(
LaravelExceptionHandlerContract::class,
ExceptionHandler::class
);
}

/**
Expand Down

2 comments on commit b9ce5ef

@tiran133
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This breaks my app.
I get following error Class 'App\Exceptions\Handler' not found

@ArturMoczulski
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your feedback. I'm working on a fix now (#56)

Please sign in to comment.