Fix auto-deploy not throwing proper exception

This commit is contained in:
Dane Everitt 2016-10-07 14:26:37 -04:00
parent b850256657
commit 9d55e93e9e
No known key found for this signature in database
GPG key ID: EEA66103B3D71F53
2 changed files with 6 additions and 2 deletions

View file

@ -61,9 +61,12 @@ class DeploymentService
*/
public static function randomNode($location, array $not = [])
{
$useLocation = Models\Location::findOrFail($location);
$node = Models\Node::where('location', $useLocation->id)->where('public', 1)->whereNotIn('id', $not)->inRandomOrder()->first();
$useLocation = Models\Location::where('id', $location)->first();
if (!$useLocation) {
throw new DisplayException("The location passed was not valid and could not be found.");
}
$node = Models\Node::where('location', $useLocation->id)->where('public', 1)->whereNotIn('id', $not)->inRandomOrder()->first();
if (!$node) {
throw new DisplayException("Unable to find a node in location {$useLocation->short} (id: {$useLocation->id}) that is available and has space.");
}