From 776cea7055fb07d768d8645a5b0ba807cb897e02 Mon Sep 17 00:00:00 2001 From: Nabeel Shahzad Date: Sat, 17 Mar 2018 18:07:13 -0500 Subject: [PATCH] Add error handler when trying to invoke in ClassLoader --- app/Support/ClassLoader.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/Support/ClassLoader.php b/app/Support/ClassLoader.php index a8655200..e8661efe 100644 --- a/app/Support/ClassLoader.php +++ b/app/Support/ClassLoader.php @@ -3,6 +3,7 @@ namespace App\Support; use Symfony\Component\ClassLoader\ClassMapGenerator; +use Log; class ClassLoader { @@ -20,7 +21,13 @@ class ClassLoader $all_classes = array_keys(ClassMapGenerator::createMap($path)); foreach ($all_classes as $cl) { - $klass = new $cl; + try { + $klass = new $cl; + } catch (\Exception $e) { + Log::error('Error loading class: ' . $e->getMessage()); + continue; + } + $classes[] = $klass; }