From b2cd7cc5c94cc20c69813c5558b8ce463906b422 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Wed, 28 Sep 2016 17:32:08 -0400 Subject: [PATCH] Throw exception if no allocation is there. --- app/Services/DeploymentService.php | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/app/Services/DeploymentService.php b/app/Services/DeploymentService.php index 957b80495..ff2f16cbc 100644 --- a/app/Services/DeploymentService.php +++ b/app/Services/DeploymentService.php @@ -104,7 +104,12 @@ class DeploymentService */ public static function randomAllocation($node) { - return Models\Allocation::where('node', $node)->whereNull('assigned_to')->inRandomOrder()->first(); + $allocation = Models\Allocation::where('node', $node)->whereNull('assigned_to')->inRandomOrder()->first(); + if (!$allocation) { + throw new DisplayException('No available allocation could be found for the assigned node.'); + } + + return $allocation; } /**