- Add handler

This commit is contained in:
Vincent BRIDIER 2022-01-17 13:12:18 +01:00
parent b19fd25772
commit e95e78d7cf
6 changed files with 83 additions and 28 deletions

View file

@ -27,6 +27,7 @@ MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS=null
MAIL_FROM_NAME="${APP_NAME}"
MAIL_HANDLER=
SAML2_ldc_IDP_HOST=
SAML2_ldc_SP_x509=

View file

@ -3,7 +3,7 @@
namespace App\Exceptions;
use Throwable;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Kwaadpepper\ExceptionHandler\Exceptions\ExceptionHandler;
use Illuminate\Support\Facades\Mail;
class Handler extends ExceptionHandler
@ -37,27 +37,7 @@ class Handler extends ExceptionHandler
*/
public function report(Throwable $e)
{
try {
if (!config('app.debug')) {
if ($this->shouldntReport($e)) {
return;
}
Mail::send('emails.exception', [
'url' => app()->runningInConsole() ?
'CONSOLE' : (
(request() and request()->fullUrl()) ?
request()->fullUrl() : 'none'),
'exception' => $e
], function ($m) {
$m->to(
config('mail.contactsList.serviceweb'),
'LDC WEB Exception Handler'
)->subject('Need help !, an error occured in your application, please check Logs ASAP');
});
}
} finally {
parent::report($e);
}
parent::report($e);
}
/**

View file

@ -13,6 +13,7 @@
"fideloper/proxy": "^4.0",
"guzzlehttp/guzzle": "^7.0.1",
"kwaadpepper/enum": "^2.1",
"kwaadpepper/exception-handler": "^0.0.6",
"laravel/framework": "^8.0",
"laravel/tinker": "^2.0",
"laravel/ui": "^3.0",

63
composer.lock generated
View file

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "b546dbc8d9f1a4864d858dcaf069e333",
"content-hash": "ed658d3ddd1a4ad30dc141aa79b0647c",
"packages": [
{
"name": "aacotroneo/laravel-saml2",
@ -1030,6 +1030,67 @@
},
"time": "2021-11-18T16:52:08+00:00"
},
{
"name": "kwaadpepper/exception-handler",
"version": "0.0.6",
"source": {
"type": "git",
"url": "https://github.com/Kwaadpepper/exception-handler.git",
"reference": "9e17a9c0a43755d91cb98717e3fc7ba17db0c1c7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Kwaadpepper/exception-handler/zipball/9e17a9c0a43755d91cb98717e3fc7ba17db0c1c7",
"reference": "9e17a9c0a43755d91cb98717e3fc7ba17db0c1c7",
"shasum": ""
},
"require": {
"illuminate/support": "~7|~8",
"laravel/framework": "~7|~8"
},
"require-dev": {
"orchestra/testbench": "^6.13",
"phpunit/phpunit": "~9.0",
"squizlabs/php_codesniffer": "^3.5"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Kwaadpepper\\ExceptionHandler\\ExceptionHandlerServiceProvider"
]
}
},
"autoload": {
"psr-4": {
"Kwaadpepper\\ExceptionHandler\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Jérémy Munsch",
"email": "github@jeremydev.ovh",
"homepage": "https://jeremydev.ovh"
}
],
"description": "Send emails when exceptions occurs",
"homepage": "https://github.com/kwaadpepper/exception-handler",
"keywords": [
"email",
"exception",
"laravel",
"policies"
],
"support": {
"issues": "https://github.com/Kwaadpepper/exception-handler/issues",
"source": "https://github.com/Kwaadpepper/exception-handler/tree/0.0.6"
},
"time": "2021-12-01T08:54:11+00:00"
},
{
"name": "laravel/framework",
"version": "v8.79.0",

View file

@ -0,0 +1,17 @@
<?php
return [
/**
* Send mail when app debug is turn off
* so you can be warned if an unhandled exception occurs
*/
'enableMaiLog' => !config('app.debug'),
/**
* Put a developper secured mailbox in here
* so you can receive email if things go mad
*/
'contactsList' => [
env('MAIL_HANDLER', 'equipe.web@ldc.fr')
]
];

View file

@ -60,11 +60,6 @@ return [
'name' => env('MAIL_FROM_NAME', 'Example'),
],
// Contacts List
'contactsList' => [
'serviceweb' => env('MAIL_LIST_SERVICEWEB', 'informatique.internet@ldc.fr'),
],
/*
|--------------------------------------------------------------------------
| E-Mail Encryption Protocol