mirror of
https://github.com/retailcrm/graphql-php.git
synced 2024-11-26 06:46: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) {
|
} else if ($error instanceof \Exception) {
|
||||||
$message = $error->getMessage();
|
$message = $error->getMessage();
|
||||||
$originalError = $error;
|
$originalError = $error;
|
||||||
|
} else if ($error instanceof \Error) {
|
||||||
|
$message = $error->getMessage();
|
||||||
|
$originalError = $error;
|
||||||
} else {
|
} else {
|
||||||
$message = (string) $error;
|
$message = (string) $error;
|
||||||
}
|
}
|
||||||
@ -119,9 +122,9 @@ class Error extends \Exception implements \JsonSerializable
|
|||||||
* @param Source $source
|
* @param Source $source
|
||||||
* @param array|null $positions
|
* @param array|null $positions
|
||||||
* @param array|null $path
|
* @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);
|
parent::__construct($message, 0, $previous);
|
||||||
|
|
||||||
|
@ -680,6 +680,8 @@ class Executor
|
|||||||
return $resolveFn($source, $args, $context, $info);
|
return $resolveFn($source, $args, $context, $info);
|
||||||
} catch (\Exception $error) {
|
} catch (\Exception $error) {
|
||||||
return $error;
|
return $error;
|
||||||
|
} catch (\Error $error) {
|
||||||
|
return $error;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,6 +780,8 @@ class Executor
|
|||||||
return $completed;
|
return $completed;
|
||||||
} catch (\Exception $error) {
|
} catch (\Exception $error) {
|
||||||
throw Error::createLocatedError($error, $fieldNodes, $path);
|
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
|
* @return array|null|Promise
|
||||||
* @throws Error
|
* @throws Error
|
||||||
* @throws \Exception
|
* @throws \Exception
|
||||||
|
* @throws \Error
|
||||||
*/
|
*/
|
||||||
private function completeValue(
|
private function completeValue(
|
||||||
Type $returnType,
|
Type $returnType,
|
||||||
@ -835,6 +840,10 @@ class Executor
|
|||||||
throw $result;
|
throw $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($result instanceof \Error) {
|
||||||
|
throw $result;
|
||||||
|
}
|
||||||
|
|
||||||
// If field type is NonNull, complete for inner type, and throw field error
|
// If field type is NonNull, complete for inner type, and throw field error
|
||||||
// if result is null.
|
// if result is null.
|
||||||
if ($returnType instanceof NonNull) {
|
if ($returnType instanceof NonNull) {
|
||||||
|
Loading…
Reference in New Issue
Block a user