From 5df386524d6ad12c25103e752600674b86dd2064 Mon Sep 17 00:00:00 2001 From: Gerry Demaret Date: Wed, 25 Mar 2026 09:53:47 +0100 Subject: [PATCH] Locator: pass on last exception message Currently, the exception thrown in Locator is not very informative. Having a hint of why the failure occurred would help debugging. --- src/Locator/Locator.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/Locator/Locator.php b/src/Locator/Locator.php index 13072ff..0a0260d 100644 --- a/src/Locator/Locator.php +++ b/src/Locator/Locator.php @@ -650,6 +650,7 @@ private function waitForCondition(callable $condition, int $timeoutMs, string $m { $start = microtime(true); $timeoutSeconds = $timeoutMs / 1000; + $lastExceptionMessage = ''; while ((microtime(true) - $start) < $timeoutSeconds) { try { @@ -657,12 +658,13 @@ private function waitForCondition(callable $condition, int $timeoutMs, string $m return; } } catch (PlaywrightException $e) { + $lastExceptionMessage = $e->getMessage(); } usleep(100000); } - throw new TimeoutException(sprintf('%s (timeout: %dms)', $message, $timeoutMs)); + throw new TimeoutException(sprintf('%s (timeout: %dms): %s', $message, $timeoutMs, $lastExceptionMessage)); } /**