Catch packet errors and display a nice error

This commit is contained in:
Deon George 2021-06-29 23:42:35 +10:00
parent 7356bedfa2
commit 16a1d8a440
2 changed files with 20 additions and 1 deletions

View File

@ -43,7 +43,13 @@ class HomeController extends Controller
continue; continue;
foreach ($filegroup as $file) { foreach ($filegroup as $file) {
$pkt = new Packet($file); try {
$pkt = new Packet($file);
} catch (\Exception $e) {
return redirect()->back()->withErrors($e->getMessage());
}
break; break;
} }
} }

View File

@ -26,6 +26,19 @@
</div> </div>
</div> </div>
@if($errors->count())
<div class="row">
<span class="pl-5 btn btn-sm btn-danger" role="alert" style="text-align: left;">
There were errors with the submission.
<ul>
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</span>
</div>
@endif
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<a href="{{ url('/') }}" class="btn btn-danger">Cancel</a> <a href="{{ url('/') }}" class="btn btn-danger">Cancel</a>