Skip to content

Commit 34dfe55

Browse files
committed
Merge branch 'master' of github.com:jeremykenedy/laravel-exception-notifier
2 parents 5fa6593 + 17eaa1c commit 34dfe55

File tree

4 files changed

+18
-32
lines changed

4 files changed

+18
-32
lines changed

src/App/Mail/ExceptionOccured.php

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
use Illuminate\Bus\Queueable;
66
use Illuminate\Mail\Mailable;
77
use Illuminate\Queue\SerializesModels;
8-
use Illuminate\Contracts\Queue\ShouldQueue;
98

109
class ExceptionOccured extends Mailable
1110
{
@@ -30,12 +29,11 @@ public function __construct($content)
3029
*/
3130
public function build()
3231
{
33-
34-
$emailsTo = str_getcsv(config('exceptions.emailExceptionsTo'),',');
35-
$ccEmails = str_getcsv(config('exceptions.emailExceptionCCto'),',');
36-
$bccEmails = str_getcsv(config('exceptions.emailExceptionBCCto'),',');
32+
$emailsTo = str_getcsv(config('exceptions.emailExceptionsTo'), ',');
33+
$ccEmails = str_getcsv(config('exceptions.emailExceptionCCto'), ',');
34+
$bccEmails = str_getcsv(config('exceptions.emailExceptionBCCto'), ',');
3735
$fromSender = config('exceptions.emailExceptionFrom');
38-
$subject = config('exceptions.emailExceptionSubject');
36+
$subject = config('exceptions.emailExceptionSubject');
3937

4038
if ($emailsTo[0] == null) {
4139
$emailsTo = config('exceptions.emailExceptionsToDefault');

src/App/Traits/ExceptionNotificationHandlerTrait.php

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,11 @@
55
use App\Mail\ExceptionOccured;
66
use Illuminate\Support\Facades\Log;
77
use Mail;
8-
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
98
use Symfony\Component\Debug\Exception\FlattenException;
9+
use Symfony\Component\Debug\ExceptionHandler as SymfonyExceptionHandler;
1010

1111
trait ExceptionNotificationHandlerTrait
1212
{
13-
1413
/**
1514
* A list of the exception types that should not be reported.
1615
*
@@ -30,15 +29,15 @@ trait ExceptionNotificationHandlerTrait
3029
*
3130
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
3231
*
33-
* @param \Exception $exception
32+
* @param \Exception $exception
33+
*
3434
* @return void
3535
*/
3636
public function report(Exception $exception)
3737
{
38-
3938
$enableEmailExceptions = config('exceptions.emailExceptionEnabled');
4039

41-
if ($enableEmailExceptions === "") {
40+
if ($enableEmailExceptions === '') {
4241
$enableEmailExceptions = config('exceptions.emailExceptionEnabledDefault');
4342
}
4443

@@ -54,25 +53,20 @@ public function report(Exception $exception)
5453
/**
5554
* Sends an email upon exception.
5655
*
57-
* @param \Exception $exception
56+
* @param \Exception $exception
57+
*
5858
* @return void
5959
*/
6060
public function sendEmail(Exception $exception)
6161
{
6262
try {
63-
6463
$e = FlattenException::create($exception);
6564
$handler = new SymfonyExceptionHandler();
6665
$html = $handler->getHtml($e);
6766

6867
Mail::send(new ExceptionOccured($html));
69-
7068
} catch (Exception $exception) {
71-
7269
Log::error($exception);
73-
7470
}
7571
}
76-
77-
7872
}

src/LaravelExceptionNotifier.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ public function boot()
2828
$this->publishes([
2929
__DIR__.'/config/exceptions.php' => config_path('exceptions.php'),
3030
], 'laravelexceptionnotifier');
31-
3231
}
3332

3433
/**
@@ -38,6 +37,5 @@ public function boot()
3837
*/
3938
public function register()
4039
{
41-
4240
}
43-
}
41+
}

src/config/exceptions.php

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
|
1212
*/
1313

14-
'emailExceptionEnabled' => env('EMAIL_EXCEPTION_ENABLED'),
14+
'emailExceptionEnabled' => env('EMAIL_EXCEPTION_ENABLED'),
1515
'emailExceptionEnabledDefault' => true,
1616

1717
/*
@@ -23,7 +23,7 @@
2323
|
2424
*/
2525

26-
'emailExceptionFrom' => env('EMAIL_EXCEPTION_FROM'),
26+
'emailExceptionFrom' => env('EMAIL_EXCEPTION_FROM'),
2727
'emailExceptionFromDefault' => 'email@email.com',
2828

2929
/*
@@ -35,7 +35,7 @@
3535
|
3636
*/
3737

38-
'emailExceptionsTo' => env('EMAIL_EXCEPTION_TO'),
38+
'emailExceptionsTo' => env('EMAIL_EXCEPTION_TO'),
3939
'emailExceptionsToDefault' => 'email@email.com',
4040

4141
/*
@@ -47,7 +47,7 @@
4747
|
4848
*/
4949

50-
'emailExceptionCCto' => env('EMAIL_EXCEPTION_CC'),
50+
'emailExceptionCCto' => env('EMAIL_EXCEPTION_CC'),
5151
'emailExceptionCCtoDefault' => [],
5252

5353
/*
@@ -59,7 +59,7 @@
5959
|
6060
*/
6161

62-
'emailExceptionBCCto' => env('EMAIL_EXCEPTION_BCC'),
62+
'emailExceptionBCCto' => env('EMAIL_EXCEPTION_BCC'),
6363
'emailExceptionBCCtoDefault' => [],
6464

6565
/*
@@ -71,8 +71,8 @@
7171
|
7272
*/
7373

74-
'emailExceptionSubject' => env('EMAIL_EXCEPTION_SUBJECT'),
75-
'emailExceptionSubjectDefault' => 'Error on ' . config('app.env'),
74+
'emailExceptionSubject' => env('EMAIL_EXCEPTION_SUBJECT'),
75+
'emailExceptionSubjectDefault' => 'Error on '.config('app.env'),
7676

7777
/*
7878
|--------------------------------------------------------------------------
@@ -86,7 +86,3 @@
8686
'emailExceptionView' => 'emails.exception',
8787

8888
];
89-
90-
91-
92-

0 commit comments

Comments
 (0)