From 8350b6bd36d3a4bb3a99dfbf67e746f4f815927c Mon Sep 17 00:00:00 2001 From: Fbenas Date: Mon, 7 May 2018 15:02:39 +0100 Subject: Add some simple exception handling for bad inputs --- src/Script/Console.php | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/Script/Console.php') diff --git a/src/Script/Console.php b/src/Script/Console.php index e1d7df5..3228750 100644 --- a/src/Script/Console.php +++ b/src/Script/Console.php @@ -5,6 +5,7 @@ namespace App\Script; use App\Model\Vendor; use App\Script\Input; use App\Script\Output; +use Exception; /** * Main application class @@ -44,12 +45,16 @@ class Console */ public function exec() { - $input = new Input; - $vendors = Vendor::loadAll($input->getOption('f')); + $output = new Output; + try { + $input = new Input; + $vendors = Vendor::loadAll($input->getOption('f')); - $vendors->filterByInput($input); + $vendors->filterByInput($input); - $output = new Output; - $output->printCollection($vendors); + $output->printCollection($vendors); + } catch (Exception $e) { + $output->printException($e); + } } } -- cgit v1.2.3