From 60b70a4074661c6e82512ce63bc3d29881641cc3 Mon Sep 17 00:00:00 2001 From: slong753 Date: Tue, 14 Mar 2023 16:07:09 -0500 Subject: [PATCH] catch and redirect back with error --- app/Http/Controllers/Assets/AssetsController.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Assets/AssetsController.php b/app/Http/Controllers/Assets/AssetsController.php index 9b51b7f267..323d238ec1 100755 --- a/app/Http/Controllers/Assets/AssetsController.php +++ b/app/Http/Controllers/Assets/AssetsController.php @@ -627,7 +627,11 @@ class AssetsController extends Controller $csv->setHeaderOffset(0); $header = $csv->getHeader(); $isCheckinHeaderExplicit = in_array('checkin date', (array_map('strtolower', $header))); - $results = $csv->getRecords(); + try { + $results = $csv->getRecords(); + } catch (\Exception $e) { + return back()->with('error', 'There was an error reading the CSV file: '.$e->getMessage()); + } $item = []; $status = []; $status['error'] = [];