File tree 2 files changed +24
-7
lines changed
2 files changed +24
-7
lines changed Original file line number Diff line number Diff line change 1
1
<?php
2
2
namespace Lio \Exceptions ;
3
3
4
+ use Bugsnag ;
4
5
use Exception ;
6
+ use Illuminate \Contracts \Auth \Guard ;
5
7
use Symfony \Component \HttpKernel \Exception \HttpException ;
6
8
use Bugsnag \BugsnagLaravel \BugsnagExceptionHandler as ExceptionHandler ;
7
9
8
10
class Handler extends ExceptionHandler
9
11
{
12
+ /**
13
+ * @var \Illuminate\Contracts\Auth\Guard
14
+ */
15
+ private $ auth ;
16
+
17
+ /**
18
+ * @param \Illuminate\Contracts\Auth\Guard $auth
19
+ */
20
+ public function __construct (Guard $ auth )
21
+ {
22
+ $ this ->auth = $ auth ;
23
+ }
24
+
10
25
/**
11
26
* A list of the exception types that should not be reported.
12
27
*
@@ -26,6 +41,14 @@ class Handler extends ExceptionHandler
26
41
*/
27
42
public function report (Exception $ e )
28
43
{
44
+ // If a user is logged in, we'll set him as the target user for which the errors will occur.
45
+ if ($ this ->auth ->check ()) {
46
+ Bugsnag::setUser ([
47
+ 'name ' => $ this ->auth ->user ()->name ,
48
+ 'email ' => $ this ->auth ->user ()->email ,
49
+ ]);
50
+ }
51
+
29
52
return parent ::report ($ e );
30
53
}
31
54
Original file line number Diff line number Diff line change @@ -13,13 +13,7 @@ class AppServiceProvider extends ServiceProvider
13
13
*/
14
14
public function boot ()
15
15
{
16
- // If a user is logged in, we'll set him as the target user for which the errors will occur.
17
- if ($ this ->app ['auth ' ]->check ()) {
18
- $ this ->app ['bugsnag ' ]->setUser ([
19
- 'name ' => $ this ->app ['auth ' ]->user ()->name ,
20
- 'email ' => $ this ->app ['auth ' ]->user ()->email
21
- ]);
22
- }
16
+ //
23
17
}
24
18
25
19
/**
You can’t perform that action at this time.
0 commit comments