Merge branch 'main' into small-changes

# Conflicts:
#	tests/Feature/MonthlyUsageTest.php
#	tests/Feature/VacationCalendarTest.php
#	tests/Feature/VacationRequestTest.php
This commit is contained in:
Adrian Hopek
2022-03-30 09:56:17 +02:00
6 changed files with 128 additions and 26 deletions

View File

@@ -5,6 +5,9 @@ declare(strict_types=1);
namespace Toby\Architecture;
use Illuminate\Foundation\Exceptions\Handler;
use Inertia\Inertia;
use Symfony\Component\HttpFoundation\Response;
use Throwable;
class ExceptionHandler extends Handler
{
@@ -13,4 +16,19 @@ class ExceptionHandler extends Handler
"password",
"password_confirmation",
];
public function render($request, Throwable $e): Response
{
$response = parent::render($request, $e);
if (app()->environment("production") && in_array($response->status(), [500, 503, 429, 419, 404, 403, 401], true)) {
return Inertia::render("Error", [
"status" => $response->status(),
])
->toResponse($request)
->setStatusCode($response->status());
}
return $response;
}
}