* itself we get a circular reference. We clear the $handler
* here to avoid that memory leak.
*/
$f = $handler[$index];
unset($handler);
$promise->resolve($f($value));
} elseif ($index === 1) {
// Forward resolution values as-is.
$promise->resolve($value);
} else {
// Forward rejections down the chain.
if (!is_object($value) || !method_exists($value, 'then')) {
$id = $state === self::FULFILLED ? 1 : 2;
// It's a success, so resolve the handlers in the queue.
Utils::queue()->add(static function () use ($id, $value, $handlers) {
foreach ($handlers as $handler) {
self::callHandler($id, $value, $handler);
}
});
} elseif ($value instanceof Promise && Is::pending($value)) {
// We can just merge our handlers onto the next promise.
$value->handlers = array_merge($value->handlers, $handlers);
private function waitIfPending()
{
if ($this->state !== self::PENDING) {
return;
} elseif ($this->waitFn) {
$this->invokeWaitFn();
} elseif ($this->waitList) {
$this->invokeWaitList();
} else {
// If there's no wait function, then reject the promise.
$this->reject('Cannot wait on a promise that has '
if ($this->state !== self::PENDING) {
return;
} elseif ($this->waitFn) {
$this->invokeWaitFn();
} elseif ($this->waitList) {
$this->invokeWaitList();
} else {
// If there's no wait function, then reject the promise.
$this->reject('Cannot wait on a promise that has '
. 'no internal wait function. You must provide a wait '
. 'function when constructing the promise to be able to '
$direction->name,
env('TFL_APP_KEY'),
];
$responses = Promise\Utils::unwrap([
'lineArrivals' => $client->getAsync(sprintf(TflClient::LINE_ARRIVAL_PREDICTION_URL, ...$lineArrivalsVars)),
'stopPointArrivalsRaw' => $client->getAsync(sprintf(TflClient::ARRIVAL_PREDICTION_URL, ...$stopPointArrivalsVars)),
]);
$lineArrivals = json_decode($responses['lineArrivals']->getBody(), true);
$stopPointArrivalsRaw = json_decode($responses['stopPointArrivalsRaw']->getBody(), true);
usort($lineArrivals, fn($a, $b) => strcmp($a['expectedArrival'], $b['expectedArrival']));
usort($stopPointArrivalsRaw, fn($a, $b) => strcmp($a['expectedArrival'], $b['expectedArrival']));
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
if ($this->manager->shouldBlock() ||
($request->route() instanceof Route && $request->route()->locksFor())) {
return $this->handleRequestWhileBlocking($request, $session, $next);
} else {
return $this->handleStatefulRequest($request, $session, $next);
}
}
/**
* Handle the given request within session state.
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
// since the object we're given was already a fully instantiated object.
$parameters = [$passable, $stack];
}
$carry = method_exists($pipe, $this->method)
? $pipe->{$this->method}(...$parameters)
: $pipe(...$parameters);
return $this->handleCarry($carry);
} catch (Throwable $e) {
return $this->handleException($passable, $e);
ClientException |
---|
GuzzleHttp\Exception\ClientException: Client error: `GET https://api.tfl.gov.uk/Line/650/Arrivals/490015181L?direction=outbound&app_key=18cab965158c4610acee64356fc40f9e` resulted in a `404 Not Found` response: {"$type":"Tfl.Api.Presentation.Entities.ApiError, Tfl.Api.Presentation.Entities","timestampUtc":"2024-03-29T16:01:29.688 (truncated...) at /home/forge/timetable.london/vendor/guzzlehttp/guzzle/src/Exception/RequestException.php:113 at GuzzleHttp\Exception\RequestException::create() (/home/forge/timetable.london/vendor/guzzlehttp/guzzle/src/Middleware.php:69) at GuzzleHttp\Middleware::GuzzleHttp\{closure}() (/home/forge/timetable.london/vendor/guzzlehttp/promises/src/Promise.php:204) at GuzzleHttp\Promise\Promise::callHandler() (/home/forge/timetable.london/vendor/guzzlehttp/promises/src/Promise.php:153) at GuzzleHttp\Promise\Promise::GuzzleHttp\Promise\{closure}() (/home/forge/timetable.london/vendor/guzzlehttp/promises/src/TaskQueue.php:48) at GuzzleHttp\Promise\TaskQueue->run() (/home/forge/timetable.london/vendor/guzzlehttp/promises/src/Promise.php:248) at GuzzleHttp\Promise\Promise->invokeWaitFn() (/home/forge/timetable.london/vendor/guzzlehttp/promises/src/Promise.php:224) at GuzzleHttp\Promise\Promise->waitIfPending() (/home/forge/timetable.london/vendor/guzzlehttp/promises/src/Promise.php:269) at GuzzleHttp\Promise\Promise->invokeWaitList() (/home/forge/timetable.london/vendor/guzzlehttp/promises/src/Promise.php:226) at GuzzleHttp\Promise\Promise->waitIfPending() (/home/forge/timetable.london/vendor/guzzlehttp/promises/src/Promise.php:62) at GuzzleHttp\Promise\Promise->wait() (/home/forge/timetable.london/vendor/guzzlehttp/promises/src/Utils.php:132) at GuzzleHttp\Promise\Utils::unwrap() (/home/forge/timetable.london/app/Http/Controllers/BusStopController.php:64) at App\Http\Controllers\BusStopController->index() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/Controller.php:54) at Illuminate\Routing\Controller->callAction() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/ControllerDispatcher.php:45) at Illuminate\Routing\ControllerDispatcher->dispatch() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/Route.php:254) at Illuminate\Routing\Route->runController() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/Route.php:197) at Illuminate\Routing\Route->run() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/Router.php:692) at Illuminate\Routing\Router->Illuminate\Routing\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/Middleware/SubstituteBindings.php:41) at Illuminate\Routing\Middleware\SubstituteBindings->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/app/Http/Middleware/SetDefaultLocaleForUrls.php:20) at App\Http\Middleware\SetDefaultLocaleForUrls->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/app/Http/Middleware/SetLocale.php:18) at App\Http\Middleware\SetLocale->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php:78) at Illuminate\Foundation\Http\Middleware\VerifyCsrfToken->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/View/Middleware/ShareErrorsFromSession.php:49) at Illuminate\View\Middleware\ShareErrorsFromSession->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:121) at Illuminate\Session\Middleware\StartSession->handleStatefulRequest() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php:63) at Illuminate\Session\Middleware\StartSession->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/AddQueuedCookiesToResponse.php:37) at Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Cookie/Middleware/EncryptCookies.php:67) at Illuminate\Cookie\Middleware\EncryptCookies->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103) at Illuminate\Pipeline\Pipeline->then() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/Router.php:694) at Illuminate\Routing\Router->runRouteWithinStack() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/Router.php:669) at Illuminate\Routing\Router->runRoute() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/Router.php:635) at Illuminate\Routing\Router->dispatchToRoute() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Routing/Router.php:624) at Illuminate\Routing\Router->dispatch() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:166) at Illuminate\Foundation\Http\Kernel->Illuminate\Foundation\Http\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:128) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21) at Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/TransformsRequest.php:21) at Illuminate\Foundation\Http\Middleware\TransformsRequest->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/ValidatePostSize.php:27) at Illuminate\Foundation\Http\Middleware\ValidatePostSize->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Foundation/Http/Middleware/PreventRequestsDuringMaintenance.php:87) at Illuminate\Foundation\Http\Middleware\PreventRequestsDuringMaintenance->handle() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:167) at Illuminate\Pipeline\Pipeline->Illuminate\Pipeline\{closure}() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Pipeline/Pipeline.php:103) at Illuminate\Pipeline\Pipeline->then() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:141) at Illuminate\Foundation\Http\Kernel->sendRequestThroughRouter() (/home/forge/timetable.london/vendor/laravel/framework/src/Illuminate/Foundation/Http/Kernel.php:110) at Illuminate\Foundation\Http\Kernel->handle() (/home/forge/timetable.london/public/index.php:53) |