public function completeValueCatchingError(
        TypeInterface $returnType,
        array $fieldNodes,
        ResolveInfo $info,
        array $path,
        &$result
    ) {
        try {
            $completed = $result instanceof PromiseInterface
                ? $result->then(function ($resolvedResult) use ($returnType, $fieldNodes, $info, $path) {
                    return $this->completeValue($returnType, $fieldNodes, $info, $path, $resolvedResult);
                })
                : $this->completeValue($returnType, $fieldNodes, $info, $path, $result);

            if ($completed instanceof PromiseInterface) {
                // Note: we don't rely on a `catch` method, but we do expect "thenable"
                // to take a second callback for the error case.
                return $completed->then(null, function ($exception) use ($fieldNodes, $path, $returnType) {
                    $this->handleFieldError($exception, $fieldNodes, $path, $returnType);
                });
            }

            return $completed;
        } catch (\Throwable $exception) {
            $this->handleFieldError($exception, $fieldNodes, $path, $returnType);
            return null;
        }
    }
public function completeValueCatchingError(
        TypeInterface $returnType,
        array $fieldNodes,
        ResolveInfo $info,
        array $path,
        &$result
    ) {
        try {
            $completed = $result instanceof PromiseInterface
                ? $result->then(function ($resolvedResult) use ($returnType, $fieldNodes, $info, $path) {
                    return $this->completeValue($returnType, $fieldNodes, $info, $path, $resolvedResult);
                })
                : $this->completeValue($returnType, $fieldNodes, $info, $path, $result);

            if ($completed instanceof PromiseInterface) {
                // Note: we don't rely on a `catch` method, but we do expect "thenable"
                // to take a second callback for the error case.
                return $completed->then(null, function ($exception) use ($fieldNodes, $path, $returnType) {
                    $this->handleFieldError($exception, $fieldNodes, $path, $returnType);
                });
            }

            return $completed;
        } catch (\Throwable $exception) {
            $this->handleFieldError($exception, $fieldNodes, $path, $returnType);
            return null;
        }
    }
public function completeValueCatchingError ( TypeInterface $ returnType , array $ fieldNodes , ResolveInfo $ info , array $ path , & $ result ) { try { $ completed = $ result instanceof PromiseInterface ? $ result -> then ( function ( $ resolvedResult ) use ( $ returnType , $ fieldNodes , $ info , $ path ) { return $ this -> completeValue ( $ returnType , $ fieldNodes , $ info , $ path , $ resolvedResult ) ; } ) : $ this -> completeValue ( $ returnType , $ fieldNodes , $ info , $ path , $ result ) ; if ( $ completed instanceof PromiseInterface ) { // Note: we don't rely on a `catch` method, but we do expect "thenable" // to take a second callback for the error case. return $ completed -> then ( null , function ( $ exception ) use ( $ fieldNodes , $ path , $ returnType ) { $ this -> handleFieldError ( $ exception , $ fieldNodes , $ path , $ returnType ) ; } ) ; } return $ completed ; } catch ( \ Throwable $ exception ) { $ this -> handleFieldError ( $ exception , $ fieldNodes , $ path , $ returnType ) ; return null ; } }
This is a small wrapper around completeValue which detects and logs error in the execution context.

@param TypeInterface $returnType
@param FieldNode[]   $fieldNodes
@param ResolveInfo   $info
@param array         $path
@param mixed         $result

@return array|null|PromiseInterface
@throws \Throwable
This is a small wrapper around completeValue which detects and logs error in the execution context .