diff --git a/src/Models/Environment.php b/src/Models/Environment.php index f92754e38..e483ca773 100755 --- a/src/Models/Environment.php +++ b/src/Models/Environment.php @@ -1019,8 +1019,10 @@ function ($domain) { $domain = array_pop($domains); $attempt = 0; $success = false; + $lastError = null; while ($attempt < $maxRetries && !$success) { + $lastError = null; $attempt++; try { $response = $this->request()->request( @@ -1036,10 +1038,7 @@ function ($domain) { ]; } } catch (\Exception $e) { - $this->logger->debug( - "Failed to wake the site:\n{message}", - ['message' => $e->getMessage(),] - ); + $lastError = $e; $success = false; } @@ -1048,6 +1047,12 @@ function ($domain) { } } + if ($lastError) { + throw new TerminusException( + 'Failed to wake the site after ' . $maxRetries . ' attempts. Last error: ' . $lastError->getMessage() + ); + } + throw new TerminusException('Failed to wake the site after ' . $maxRetries . ' attempts.'); }