From 8c7ce6984d312e3f99297ad5015001c278423249 Mon Sep 17 00:00:00 2001 From: "kreaweb.be" Date: Mon, 29 Apr 2024 08:46:01 +0200 Subject: [PATCH] Bugfix: Backup error handling --- app/Http/Controllers/Back/BackupController.php | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Back/BackupController.php b/app/Http/Controllers/Back/BackupController.php index 35c324f..3bf2382 100644 --- a/app/Http/Controllers/Back/BackupController.php +++ b/app/Http/Controllers/Back/BackupController.php @@ -3,7 +3,6 @@ namespace App\Http\Controllers\Back; use App\Http\Controllers\Controller; -use Exception; use Illuminate\Support\Carbon; use Illuminate\Support\Facades\Artisan; use Illuminate\Support\Facades\Log; @@ -82,10 +81,10 @@ public function index() public function create() { - try { - Artisan::call('backup:run --only-db'); - $output = Artisan::output(); + $exitCode = Artisan::call('backup:run --only-db'); + $output = Artisan::output(); + if ($exitCode == 0) { Log::info("Backup (Manually) -- Backup started \r\n" . $output); $notification = [ @@ -93,13 +92,13 @@ public function create() 'title' => 'Backups ...', 'message' => 'The backup was created.', ]; - } catch (Exception $e) { - Log::info("Backup (Manually) -- Backup failed \r\n" . $e->getMessage()); + } else { + Log::error("Backup (Manually) -- Backup failed \r\n" . $output); $notification = [ 'type' => 'error', 'title' => 'Backups ...', - 'message' => $e->getMessage(), + 'message' => 'The backup failed.', ]; }