Skip to content

Commit b9ce5ef

Browse files
55: bind a Rollbar exception handler to report exceptions to rollbar
1 parent 39ec203 commit b9ce5ef

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/ExceptionHandler.php

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
namespace Rollbar\Laravel;
4+
5+
use App\Exceptions\Handler as AppHandler;
6+
7+
class ExceptionHandler extends AppHandler
8+
{
9+
public function report(\Exception $exception)
10+
{
11+
\Rollbar\Rollbar::log(\Rollbar\Payload\Level::ERROR, $exception);
12+
13+
parent::report($exception);
14+
}
15+
}

src/RollbarServiceProvider.php

+7
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
use Rollbar\Laravel\MonologHandler;
77
use Rollbar\RollbarLogger;
88
use Rollbar\Rollbar;
9+
use Illuminate\Contracts\Debug\ExceptionHandler as LaravelExceptionHandlerContract;
10+
use Rollbar\Laravel\ExceptionHandler;
911

1012
class RollbarServiceProvider extends ServiceProvider
1113
{
@@ -55,6 +57,11 @@ public function register()
5557

5658
return $handler;
5759
});
60+
61+
$this->app->bind(
62+
LaravelExceptionHandlerContract::class,
63+
ExceptionHandler::class
64+
);
5865
}
5966

6067
/**

0 commit comments

Comments
 (0)