diff --git a/src/Actions/CallMethod.php b/src/Actions/CallMethod.php index 2057dc2..d660369 100644 --- a/src/Actions/CallMethod.php +++ b/src/Actions/CallMethod.php @@ -3,7 +3,6 @@ namespace Livewire\Volt\Actions; use Closure; -use Livewire\Exceptions\MissingRulesException; use Livewire\Exceptions\PropertyNotFoundException; use Livewire\Volt\CompileContext; use Livewire\Volt\Component; @@ -42,10 +41,6 @@ public function execute(CompileContext $context, Component $component, array $ar $e, "State definition for [$propertyName] not found on component [{$component->voltComponentName()}]." ); - throw $e; - } catch (MissingRulesException $e) { - Reflection::setExceptionMessage($e, "[rules()] declaration not found in [{$component->voltComponentName()}]."); - throw $e; } } diff --git a/src/LivewireManager.php b/src/LivewireManager.php index 24d39c3..a0a3c32 100644 --- a/src/LivewireManager.php +++ b/src/LivewireManager.php @@ -3,6 +3,7 @@ namespace Livewire\Volt; use Livewire\Exceptions\MethodNotFoundException; +use Livewire\Exceptions\MissingRulesException; use Livewire\LivewireManager as BaseLivewireManager; use Livewire\Volt\Actions\InitializeState; use Livewire\Volt\Support\Reflection; @@ -43,6 +44,17 @@ public function update($snapshot, $diff, $calls) Reflection::setExceptionMessage($e, "Method or action [$method] does not exist on component [{$componentInstance->voltComponentName()}]."); } + throw $e; + } catch (MissingRulesException $e) { + $componentInstance = $this->current(); + + if ($componentInstance instanceof Component) { + Reflection::setExceptionMessage( + $e, + "Missing [\$rules/rules()] property/method on: [{$componentInstance->voltComponentName()}].", + ); + } + throw $e; } } diff --git a/tests/Feature/ClassComponentTest.php b/tests/Feature/ClassComponentTest.php index 38ae426..cc4a251 100644 --- a/tests/Feature/ClassComponentTest.php +++ b/tests/Feature/ClassComponentTest.php @@ -55,7 +55,7 @@ ->call('store'); })->throws( MissingRulesException::class, - 'Missing [$rules/rules()] property/method on Livewire component: [component-with-missing-rules].', + 'Missing [$rules/rules()] property/method on: [component-with-missing-rules].', ); it('throws exception when method is not found within action', function () { diff --git a/tests/Feature/FunctionalComponentTest.php b/tests/Feature/FunctionalComponentTest.php index 8f4b8d4..7c640fc 100644 --- a/tests/Feature/FunctionalComponentTest.php +++ b/tests/Feature/FunctionalComponentTest.php @@ -318,7 +318,7 @@ public function render() ->call('store'); })->throws( MissingRulesException::class, - '[rules()] declaration not found in [component-with-missing-rules].', + 'Missing [$rules/rules()] property/method on: [component-with-missing-rules].', ); it('throws exception when method is not found within action', function () {