createRejectedPromise() публичный Метод

Creates a rejected promise for a reason if the reason is not a promise. If the provided reason is a promise, then it is returned as-is.
public createRejectedPromise ( mixed $reason ) : GraphQL\Executor\Promise\Promise
$reason mixed
Результат GraphQL\Executor\Promise\Promise a rejected promise
Пример #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);
     }
 }