2 Commits

Author SHA1 Message Date
2f2e0f78e9 errors handled in the correct log file 2025-05-27 14:42:10 +02:00
Clément
f4aa84a82d handled errors properly 2025-05-12 16:42:41 +02:00
14 changed files with 23 additions and 1 deletions

View File

@@ -6,6 +6,8 @@ use App\Http\Requests\StoreBilletRequest;
use App\Http\Requests\UpdateBilletRequest; use App\Http\Requests\UpdateBilletRequest;
use App\Models\Billet; use App\Models\Billet;
use Illuminate\Support\Facades\Log;
class BilletController extends Controller class BilletController extends Controller
{ {
/** /**
@@ -13,7 +15,13 @@ class BilletController extends Controller
*/ */
public function index() public function index()
{ {
Log::info("coucou");
try {
$billets = Billet::all(); $billets = Billet::all();
} catch (\Illuminate\Database\QueryException $e) {
Log::channel('projectError')->error('Erreur d\'accès à la base de données');
return view('errors.unavailable');
}
return view('index', compact('billets')); return view('index', compact('billets'));
} }

View File

@@ -127,6 +127,12 @@ return [
'path' => storage_path('logs/laravel.log'), 'path' => storage_path('logs/laravel.log'),
], ],
"projectError" => [
'driver' => 'single',
'path' => storage_path('logs/project.log'),
'level' => 'error',
],
], ],
]; ];

View File

@@ -0,0 +1,4 @@
@extends('layout')
@section('contenu')
<h2>La page demandée n'est pas disponible</h2>
@endsection

View File

@@ -0,0 +1,4 @@
@extends('layout')
@section('contenu')
<h2>La ressource demandée n'est pas disponible</h2>
@endsection

0
laravel/storage/app/.gitignore vendored Normal file → Executable file
View File

0
laravel/storage/app/private/.gitignore vendored Normal file → Executable file
View File

0
laravel/storage/app/public/.gitignore vendored Normal file → Executable file
View File

0
laravel/storage/framework/.gitignore vendored Normal file → Executable file
View File

0
laravel/storage/framework/cache/.gitignore vendored Normal file → Executable file
View File

0
laravel/storage/framework/cache/data/.gitignore vendored Normal file → Executable file
View File

0
laravel/storage/framework/sessions/.gitignore vendored Normal file → Executable file
View File

0
laravel/storage/framework/testing/.gitignore vendored Normal file → Executable file
View File

0
laravel/storage/framework/views/.gitignore vendored Normal file → Executable file
View File

0
laravel/storage/logs/.gitignore vendored Normal file → Executable file
View File