createLocatedError() публичный статический Метод

Given an arbitrary Error, presumably thrown while attempting to execute a GraphQL operation, produce a new GraphQLError aware of the location in the document responsible for the original Error.
public static createLocatedError ( $error, array | null $nodes = null, array | null $path = null ) : Error
$error
$nodes array | null
$path array | null
Результат Error
Пример #1
0
 /**
  * This is a small wrapper around completeValue which annotates errors with
  * location information.
  *
  * @param ExecutionContext $exeContext
  * @param Type $returnType
  * @param $fieldNodes
  * @param ResolveInfo $info
  * @param $path
  * @param $result
  * @return array|null|Promise
  * @throws Error
  */
 public static function completeValueWithLocatedError(ExecutionContext $exeContext, Type $returnType, $fieldNodes, ResolveInfo $info, $path, $result)
 {
     try {
         $completed = self::completeValue($exeContext, $returnType, $fieldNodes, $info, $path, $result);
         if (self::$promiseAdapter->isPromise($completed)) {
             return $completed->then(null, function ($error) use($fieldNodes, $path) {
                 return self::$promiseAdapter->createRejectedPromise(Error::createLocatedError($error, $fieldNodes, $path));
             });
         }
         return $completed;
     } catch (\Exception $error) {
         throw Error::createLocatedError($error, $fieldNodes, $path);
     }
 }
Пример #2
0
 /**
  * This is a small wrapper around completeValue which annotates errors with
  * location information.
  *
  * @param ExecutionContext $exeContext
  * @param Type $returnType
  * @param $fieldASTs
  * @param ResolveInfo $info
  * @param $path
  * @param $result
  * @return array|null
  * @throws Error
  */
 static function completeValueWithLocatedError(ExecutionContext $exeContext, Type $returnType, $fieldASTs, ResolveInfo $info, $path, $result)
 {
     try {
         return self::completeValue($exeContext, $returnType, $fieldASTs, $info, $path, $result);
     } catch (\Exception $error) {
         throw Error::createLocatedError($error, $fieldASTs, $path);
     }
 }