Add error handler when trying to invoke in ClassLoader

This commit is contained in:
Nabeel Shahzad 2018-03-17 18:07:13 -05:00
parent 4b7cd6ce6e
commit 776cea7055

View File

@ -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;
}