-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* #69 - redirect back when 405 occurs * #69 - add custom error page * #7 - handle different types of errors * #69 - handle different types of errors * #69 - change text size * #69 - fix * #69 - csf * #69 - fix duplicate call of StartSession::class in Kernel.php * #69 - don't show auth dialog * #69 - fix test * #69 - add custom messages to popular statuses, handle all errors * #69 - add translations * #69 - get rid of assertStatus() in tests * #69 - delete name of queue, quick map fix and favorite button improvement
- Loading branch information
Showing
21 changed files
with
227 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace App\Exceptions; | ||
|
||
use Illuminate\Foundation\Exceptions\Handler; | ||
use Illuminate\Support\Facades\Crypt; | ||
use Inertia\Inertia; | ||
use Symfony\Component\HttpFoundation\Response; | ||
use Throwable; | ||
|
||
class ExceptionHandler extends Handler | ||
{ | ||
protected $dontFlash = [ | ||
"current_password", | ||
"password", | ||
"password_confirmation", | ||
]; | ||
|
||
public function render($request, Throwable $e) | ||
{ | ||
$response = parent::render($request, $e); | ||
$statusCode = $response->status(); | ||
|
||
app()->setLocale("en"); | ||
|
||
$encryptedCookie = $request->cookie("locale"); | ||
|
||
if ($encryptedCookie) { | ||
if (in_array($encryptedCookie, ["pl", "en"], true)) { | ||
app()->setLocale($encryptedCookie); | ||
} else { | ||
$decryptedCookie = Crypt::decryptString($encryptedCookie); | ||
|
||
$languageCode = substr($decryptedCookie, strpos($decryptedCookie, "|") + 1); | ||
|
||
if (in_array($languageCode, ["pl", "en"], true)) { | ||
app()->setLocale($languageCode); | ||
} | ||
} | ||
} | ||
|
||
switch ($statusCode) { | ||
case Response::HTTP_INTERNAL_SERVER_ERROR: | ||
case Response::HTTP_SERVICE_UNAVAILABLE: | ||
case Response::HTTP_TOO_MANY_REQUESTS: | ||
$statusTitle = __($response->statusText()); | ||
$statusDescription = $this->getDescriptionByStatusCode($statusCode); | ||
|
||
break; | ||
case 419: | ||
$statusTitle = __("Session Expired"); | ||
$statusDescription = __("Description: Session expired"); | ||
|
||
break; | ||
default: | ||
$statusTitle = __("Not Found"); | ||
$statusDescription = __("Description: Not found"); | ||
$statusCode = Response::HTTP_NOT_FOUND; | ||
|
||
break; | ||
} | ||
|
||
return Inertia::render("Error", [ | ||
"statusTitle" => $statusTitle, | ||
"statusDescription" => $statusDescription, | ||
"statusCode" => $statusCode, | ||
]) | ||
->toResponse($request) | ||
->setStatusCode($statusCode); | ||
} | ||
|
||
protected function getDescriptionByStatusCode(int $statusCode): string | ||
{ | ||
$descriptions = [ | ||
Response::HTTP_INTERNAL_SERVER_ERROR => __("Description: Server error"), | ||
Response::HTTP_SERVICE_UNAVAILABLE => __("Description: Server unavailable"), | ||
Response::HTTP_TOO_MANY_REQUESTS => __("Description: Too many requests"), | ||
]; | ||
|
||
return $descriptions[$statusCode] ?? __("Description: Other"); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,11 @@ | ||
{ | ||
"advert1": "There are many e-scooter providers out there, so sometimes you may feel a bit confused about which apps you should use on your trips.", | ||
"advert2": "This app will help you plan your vacations or business trips." | ||
"advert2": "This app will help you plan your vacations or business trips.", | ||
|
||
"Description: Not found": "Sorry, the page you were looking for could not be found.", | ||
"Description: Server error": "Oops! Something went wrong on our end. Please try again later.", | ||
"Description: Server unavailable": "Oops! The service is currently unavailable. Please try again later.", | ||
"Description: Too many requests": "Oops! Too many requests. Please try again later.", | ||
"Description: Session expired": "Your session has expired. Please log in and try again.", | ||
"Description: Other": "Oops. Something went wrong. Try again later." | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script setup> | ||
import { ArrowLeftIcon } from '@heroicons/vue/24/outline' | ||
defineProps({ | ||
statusTitle: String, | ||
statusDescription: String, | ||
statusCode: Number, | ||
}) | ||
</script> | ||
|
||
<template> | ||
<div class="grid min-h-screen grid-cols-1 grid-rows-[1fr,auto,1fr] bg-white lg:grid-cols-[max(50%,36rem),1fr]"> | ||
<main class="mx-auto w-full max-w-7xl px-6 py-24 sm:py-32 lg:col-span-2 lg:col-start-1 lg:row-start-2 lg:px-8"> | ||
<div class="max-w-lg"> | ||
<p class="px-0.5 text-2xl font-semibold leading-8 text-blumilk-500"> | ||
{{ statusCode }} | ||
</p> | ||
<h1 class="mt-4 text-4xl font-bold tracking-tight text-gray-800 sm:text-7xl"> | ||
{{ statusTitle }} | ||
</h1> | ||
<p class="mt-6 px-0.5 text-base leading-7 text-gray-600"> | ||
{{ statusDescription }} | ||
</p> | ||
<div class="mt-10"> | ||
<InertiaLink href="/" class="flex w-fit items-center py-4 pr-4 text-sm font-semibold leading-7 text-blumilk-500"> | ||
<ArrowLeftIcon class="mr-2 h-10 w-10" /> | ||
</InertiaLink> | ||
</div> | ||
</div> | ||
</main> | ||
|
||
<div class="hidden lg:relative lg:col-start-2 lg:row-start-1 lg:row-end-4 lg:block"> | ||
<img src="../assets/error-page-photo.jpg" alt="" class="absolute inset-0 h-full w-full object-cover"> | ||
</div> | ||
</div> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.