private static function completeValueCatchingError(ExecutionContext $exeContext, Type $returnType, $fieldNodes, ResolveInfo $info, $path, $result)
{
// If the field type is non-nullable, then it is resolved without any
// protection from errors.
if ($returnType instanceof NonNull) {
return self::completeValueWithLocatedError($exeContext, $returnType, $fieldNodes, $info, $path, $result);
}
// Otherwise, error protection is applied, logging the error and resolving
// a null value for this field if one is encountered.
try {
$completed = self::completeValueWithLocatedError($exeContext, $returnType, $fieldNodes, $info, $path, $result);
if (self::$promiseAdapter->isPromise($completed)) {
return $completed->then(null, function ($error) use($exeContext) {
$exeContext->addError($error);
return self::$promiseAdapter->createResolvedPromise(null);
});
}
return $completed;
} catch (Error $err) {
// If `completeValueWithLocatedError` returned abruptly (threw an error), log the error
// and return null.
$exeContext->addError($err);
return null;
}
}