From 812824100c45aff3391e2d801b26040a0e517b76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 8 Dec 2020 13:10:27 +0100 Subject: [PATCH] wrap getting file into try-catch --- app/Http/Controllers/InvoiceController.php | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/InvoiceController.php b/app/Http/Controllers/InvoiceController.php index 8ee5573f0d2d..891054af3033 100644 --- a/app/Http/Controllers/InvoiceController.php +++ b/app/Http/Controllers/InvoiceController.php @@ -843,8 +843,12 @@ class InvoiceController extends BaseController { $file_path = $invoice->service()->getInvoiceDeliveryNote($invoice, $invoice->invitations->first()->contact); - $file = base_path("storage/app/public/{$file_path}"); + try { + $file = base_path("public/storage/{$file_path}"); - return response()->download($file, basename($file)); + return response()->download($file, basename($file)); + } catch(\Exception $e) { + return response(['message' => 'Oops, something went wrong. Make sure you have symlink to storage/ in public/ directory.'], 500); + } } }