Skip to content

Commit 7c99f18

Browse files
committed
Better exception message for wrong classes
1 parent 82b95ff commit 7c99f18

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/Factories/AbstractWidgetFactory.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,12 @@ protected function instantiateWidget(array $params = [])
125125
$fqcn = $rootNamespace.'\\'.$this->widgetName;
126126
$widgetClass = class_exists($fqcn) ? $fqcn : $this->widgetName;
127127

128+
if (!class_exists($widgetClass)) {
129+
throw new InvalidWidgetClassException('Class "'.$widgetClass.'" does not exist');
130+
}
131+
128132
if (!is_subclass_of($widgetClass, 'Arrilot\Widgets\AbstractWidget')) {
129-
throw new InvalidWidgetClassException('Class "'.$widgetClass.'" must exist and extend "Arrilot\Widgets\AbstractWidget" class');
133+
throw new InvalidWidgetClassException('Class "'.$widgetClass.'" must extend "Arrilot\Widgets\AbstractWidget" class');
130134
}
131135

132136
$this->widget = new $widgetClass($this->widgetConfig);

0 commit comments

Comments
 (0)