From d1e9ec12f6df2b04379329a2d7925bd3e9819c56 Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Fri, 26 May 2023 22:21:27 +0000 Subject: [PATCH 1/3] Remove the json method on error handler --- .../ApplicationConfiguration.php | 2 +- app/Exceptions/ErrorHandle.php | 55 ------------------- 2 files changed, 1 insertion(+), 56 deletions(-) diff --git a/app/Configurations/ApplicationConfiguration.php b/app/Configurations/ApplicationConfiguration.php index 26c037c..fe047b6 100644 --- a/app/Configurations/ApplicationConfiguration.php +++ b/app/Configurations/ApplicationConfiguration.php @@ -15,7 +15,7 @@ class ApplicationConfiguration extends Configuration */ public function create(Loader $config): void { - // Event::on("user.created", UserCreatedListener::class); + // } /** diff --git a/app/Exceptions/ErrorHandle.php b/app/Exceptions/ErrorHandle.php index 8dd6e88..dfeb52f 100644 --- a/app/Exceptions/ErrorHandle.php +++ b/app/Exceptions/ErrorHandle.php @@ -3,10 +3,7 @@ namespace App\Exceptions; use Exception; -use PDOException; use Bow\Http\Exception\HttpException; -use Policier\Exception\TokenExpiredException; -use Policier\Exception\TokenInvalidException; use Bow\Application\Exception\BaseErrorHandler; use Bow\Http\Exception\ResponseException as HttpResponseException; use Bow\Database\Exception\NotFoundException as ModelNotFoundException; @@ -42,56 +39,4 @@ public function handle($exception): mixed ]); } } - - /** - * Send the json as response - * - * @param string $data - * @param mixed $code - * @return mixed - */ - private function json($exception, $code = null) - { - if ($exception instanceof TokenInvalidException) { - $code = 'TOKEN_INVALID'; - } - - if ($exception instanceof TokenExpiredException) { - $code = 'TOKEN_EXPIRED'; - } - - if (is_null($code)) { - if (method_exists($exception, 'getStatus')) { - $code = $exception->getStatus(); - } else { - $code = 'INTERNAL_SERVER_ERROR'; - } - } - - if (app_env("APP_ENV") == "production" && $exception instanceof PDOException) { - $message = 'Internal error occured'; - } else { - $message = $exception->getMessage(); - } - - $error = [ - 'message' => $message, - 'code' => $code, - 'time' => date('Y-m-d H:i:s') - ]; - - if (config('app.error_trace')) { - $trace = $exception->getTrace(); - } else { - $trace = []; - } - - if ($exception instanceof HttpException) { - $status = $exception->getStatusCode(); - } else { - $status = 500; - } - - return json(compact('error', 'trace'), $status); - } } From 4d992d227a8eb6e3782b3a160631cbdf4e04fce7 Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Sat, 27 May 2023 17:11:50 +0000 Subject: [PATCH 2/3] Change lang folder location --- config/translate.php | 2 +- {frontend/lang => lang}/en/validation.php | 0 {frontend/lang => lang}/en/welcome.php | 0 {frontend/lang => lang}/fr/validation.php | 0 {frontend/lang => lang}/fr/welcome.php | 0 5 files changed, 1 insertion(+), 1 deletion(-) rename {frontend/lang => lang}/en/validation.php (100%) rename {frontend/lang => lang}/en/welcome.php (100%) rename {frontend/lang => lang}/fr/validation.php (100%) rename {frontend/lang => lang}/fr/welcome.php (100%) diff --git a/config/translate.php b/config/translate.php index b7db4db..20dd61f 100644 --- a/config/translate.php +++ b/config/translate.php @@ -15,5 +15,5 @@ /** * Path to the language repeater */ - 'dictionary' => __DIR__ . '/../frontend/lang', + 'dictionary' => __DIR__ . '/../lang', ]; diff --git a/frontend/lang/en/validation.php b/lang/en/validation.php similarity index 100% rename from frontend/lang/en/validation.php rename to lang/en/validation.php diff --git a/frontend/lang/en/welcome.php b/lang/en/welcome.php similarity index 100% rename from frontend/lang/en/welcome.php rename to lang/en/welcome.php diff --git a/frontend/lang/fr/validation.php b/lang/fr/validation.php similarity index 100% rename from frontend/lang/fr/validation.php rename to lang/fr/validation.php diff --git a/frontend/lang/fr/welcome.php b/lang/fr/welcome.php similarity index 100% rename from frontend/lang/fr/welcome.php rename to lang/fr/welcome.php From 3a11aa53cb8fe8b767219109287862e6c3be245f Mon Sep 17 00:00:00 2001 From: Franck DAKIA Date: Sat, 27 May 2023 18:59:37 +0000 Subject: [PATCH 3/3] Fix typo --- app/Kernel.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Kernel.php b/app/Kernel.php index 351af52..f73090e 100644 --- a/app/Kernel.php +++ b/app/Kernel.php @@ -42,7 +42,7 @@ public function namespaces(): array } /** - * Define the app middlewares + * Define the app middleware * * @return array */