Throw exception if no allocation is there.

This commit is contained in:
Dane Everitt 2016-09-28 17:32:08 -04:00
parent 514512a40c
commit b2cd7cc5c9
No known key found for this signature in database
GPG Key ID: EEA66103B3D71F53
1 changed files with 6 additions and 1 deletions

View File

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