diff --git a/src/services/Orders.php b/src/services/Orders.php index a614e6b6e6..68f4dafde0 100644 --- a/src/services/Orders.php +++ b/src/services/Orders.php @@ -170,7 +170,7 @@ public function beforeDeleteUserHandler(ModelEvent $event): void // If there are any orders, make sure that this is not allowed. if (Order::find()->customerId($user->id)->status(null)->exists()) { - $event->isValid = false; + throw new Exception("Unable to delete a user with an existing order, user ID “{$user->id}”"); } } } diff --git a/src/services/Subscriptions.php b/src/services/Subscriptions.php index 78ef2e4b9e..240279f918 100644 --- a/src/services/Subscriptions.php +++ b/src/services/Subscriptions.php @@ -405,7 +405,7 @@ public function beforeDeleteUserHandler(ModelEvent $event): void // If there are any subscriptions, make sure that this is not allowed. if ($this->doesUserHaveSubscriptions($user->id)) { - $event->isValid = false; + throw new Exception("Unable to delete a user with an existing subscription, user ID “{$user->id}”"); } }