mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-29 16:36:02 +03:00
Added compatibility with php7 error handling.
This commit is contained in:
parent
5be0944453
commit
d022b19b4e
@ -89,6 +89,9 @@ class Error extends \Exception implements \JsonSerializable
|
||||
} else if ($error instanceof \Exception) {
|
||||
$message = $error->getMessage();
|
||||
$originalError = $error;
|
||||
} else if ($error instanceof \Error) {
|
||||
$message = $error->getMessage();
|
||||
$originalError = $error;
|
||||
} else {
|
||||
$message = (string) $error;
|
||||
}
|
||||
@ -119,9 +122,9 @@ class Error extends \Exception implements \JsonSerializable
|
||||
* @param Source $source
|
||||
* @param array|null $positions
|
||||
* @param array|null $path
|
||||
* @param \Exception $previous
|
||||
* @param \Exception|\Error $previous
|
||||
*/
|
||||
public function __construct($message, $nodes = null, Source $source = null, $positions = null, $path = null, \Exception $previous = null)
|
||||
public function __construct($message, $nodes = null, Source $source = null, $positions = null, $path = null, $previous = null)
|
||||
{
|
||||
parent::__construct($message, 0, $previous);
|
||||
|
||||
|
@ -680,6 +680,8 @@ class Executor
|
||||
return $resolveFn($source, $args, $context, $info);
|
||||
} catch (\Exception $error) {
|
||||
return $error;
|
||||
} catch (\Error $error) {
|
||||
return $error;
|
||||
}
|
||||
}
|
||||
|
||||
@ -778,6 +780,8 @@ class Executor
|
||||
return $completed;
|
||||
} catch (\Exception $error) {
|
||||
throw Error::createLocatedError($error, $fieldNodes, $path);
|
||||
} catch (\Error $error) {
|
||||
throw Error::createLocatedError($error, $fieldNodes, $path);
|
||||
}
|
||||
}
|
||||
|
||||
@ -810,6 +814,7 @@ class Executor
|
||||
* @return array|null|Promise
|
||||
* @throws Error
|
||||
* @throws \Exception
|
||||
* @throws \Error
|
||||
*/
|
||||
private function completeValue(
|
||||
Type $returnType,
|
||||
@ -835,6 +840,10 @@ class Executor
|
||||
throw $result;
|
||||
}
|
||||
|
||||
if ($result instanceof \Error) {
|
||||
throw $result;
|
||||
}
|
||||
|
||||
// If field type is NonNull, complete for inner type, and throw field error
|
||||
// if result is null.
|
||||
if ($returnType instanceof NonNull) {
|
||||
|
Loading…
Reference in New Issue
Block a user