From 16a1d8a4404221e06b821bb5169cad2d064e8dc0 Mon Sep 17 00:00:00 2001 From: Deon George Date: Tue, 29 Jun 2021 23:42:35 +1000 Subject: [PATCH] Catch packet errors and display a nice error --- app/Http/Controllers/HomeController.php | 8 +++++++- resources/views/pkt/debug.blade.php | 13 +++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/HomeController.php b/app/Http/Controllers/HomeController.php index 2d8f72d..cba0f27 100644 --- a/app/Http/Controllers/HomeController.php +++ b/app/Http/Controllers/HomeController.php @@ -43,7 +43,13 @@ class HomeController extends Controller continue; foreach ($filegroup as $file) { - $pkt = new Packet($file); + try { + $pkt = new Packet($file); + + } catch (\Exception $e) { + return redirect()->back()->withErrors($e->getMessage()); + } + break; } } diff --git a/resources/views/pkt/debug.blade.php b/resources/views/pkt/debug.blade.php index 1b85ea9..00f8016 100644 --- a/resources/views/pkt/debug.blade.php +++ b/resources/views/pkt/debug.blade.php @@ -26,6 +26,19 @@ + @if($errors->count()) +
+ + There were errors with the submission. +
    + @foreach ($errors->all() as $error) +
  • {{ $error }}
  • + @endforeach +
+
+
+ @endif +