mirror of
https://github.com/LinkStackOrg/LinkStack.git
synced 2025-04-01 04:10:44 +02:00
Enhance exception handling in the Handler class and improve error display in dashboard-error view
This commit is contained in:
parent
3c1ebbcbd2
commit
1cf1ab79d5
@ -42,28 +42,32 @@ class Handler extends ExceptionHandler
|
||||
|
||||
$this->renderable(function (Throwable $e, Request $request) {
|
||||
|
||||
try {
|
||||
// Check if the request matches a specific route
|
||||
if ($request->is('dashboard') ||
|
||||
$request->is('dashboard/*') ||
|
||||
$request->is('admin/*') ||
|
||||
$request->is('studio/*')) {
|
||||
|
||||
// Handle 404 errors for this specific route
|
||||
if ($e instanceof NotFoundHttpException) {
|
||||
$message = "The page you are looking for was not found.";
|
||||
return response()->view('errors.dashboard-error', compact('message'), 404);
|
||||
}
|
||||
if ($e->getPrevious() instanceof \Illuminate\Session\TokenMismatchException) {
|
||||
|
||||
// Handle general exceptions for this specific route
|
||||
|
||||
$error = $e;
|
||||
$message = $e->getMessage();
|
||||
return response()->view('errors.dashboard-error', compact(['error', 'message']), 500);
|
||||
return redirect()->route('login')->withErrors(['email' => 'Your session has expired. Please log in again.']);
|
||||
|
||||
}
|
||||
|
||||
// Default exception handling for other routes
|
||||
return parent::render($request, $e);
|
||||
try {
|
||||
$patterns = ['dashboard', 'dashboard/*', 'admin/*', 'studio/*'];
|
||||
|
||||
if (collect($patterns)->contains(fn($pattern) => $request->is($pattern))) {
|
||||
|
||||
if ($e instanceof NotFoundHttpException) {
|
||||
|
||||
$message = "The page you are looking for was not found.";
|
||||
|
||||
return response()->view('errors.dashboard-error', compact('message'), 404);
|
||||
|
||||
}
|
||||
|
||||
$error = $e;
|
||||
$message = $e->getMessage();
|
||||
|
||||
return response()->view('errors.dashboard-error', compact(['error', 'message']), 500);
|
||||
|
||||
}
|
||||
|
||||
} catch (Throwable $e) {}
|
||||
|
||||
});
|
||||
|
@ -35,9 +35,14 @@
|
||||
<div class="col-md-12">
|
||||
<div class="alert alert-danger mb-0" role="alert">
|
||||
@php
|
||||
preg_match('/^(.*?)\s?\((.*?)\)$/', $message, $matches);
|
||||
$outside = $matches[1];
|
||||
$inside = $matches[2];
|
||||
try {
|
||||
preg_match('/^(.*?)\s?\((.*?)\)$/', $message, $matches);
|
||||
$outside = $matches[1];
|
||||
$inside = $matches[2];
|
||||
} catch (\Throwable $th) {
|
||||
$outside = $message;
|
||||
$inside = '';
|
||||
}
|
||||
@endphp
|
||||
<h4 class="alert-heading">{{$outside}}</h4>
|
||||
<p>{{$inside}}</p>
|
||||
|
Loading…
x
Reference in New Issue
Block a user