DataLoaderPhp is a generic utility to be used as part of your application's data fetching layer to provide a simplified and consistent API over various remote data sources such as databases or web services via batching and caching.
PHP7 introduced the concept of Errors in addition to Exceptions. (Both implement the shared \Throwable interface).
Current behaviour of await() is to check if $rejectedReason is an \Exception, but this does not include errors like TypeError. So when a TypeError is thrown in the promise chain, it is discarded in await() and this makes for some hard to debug situations.
Would you be open for a pull request which checks for Throwable $rejectReasons as well?
if ($isPromiseCompleted) {
// rejected ?
if ($rejectedReason instanceof \Exception || (interface_exists('\Throwable') && $rejectedReason instanceof \Throwable)) {
if (!$unwrap) {
return $rejectedReason;
}
throw $rejectedReason;
}
return $resolvedValue;
}
PHP7 introduced the concept of Errors in addition to Exceptions. (Both implement the shared \Throwable interface).
Current behaviour of
await()
is to check if$rejectedReason
is an\Exception
, but this does not include errors likeTypeError
. So when aTypeError
is thrown in the promise chain, it is discarded inawait()
and this makes for some hard to debug situations.Would you be open for a pull request which checks for Throwable
$rejectReasons
as well?