mirror of
https://github.com/retailcrm/graphql-php.git
synced 2025-02-06 07:49:24 +03:00
Renamed error category constants
This commit is contained in:
parent
4634f214ea
commit
a50c9a4c1f
@ -16,8 +16,8 @@ use GraphQL\Utils\Utils;
|
|||||||
*/
|
*/
|
||||||
class Error extends \Exception implements \JsonSerializable, ClientAware
|
class Error extends \Exception implements \JsonSerializable, ClientAware
|
||||||
{
|
{
|
||||||
const GRAPHQL = 'graphql';
|
const CATEGORY_GRAPHQL = 'graphql';
|
||||||
const INTERNAL = 'internal';
|
const CATEGORY_INTERNAL = 'internal';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A message describing the Error for debugging purposes.
|
* A message describing the Error for debugging purposes.
|
||||||
@ -161,13 +161,13 @@ class Error extends \Exception implements \JsonSerializable, ClientAware
|
|||||||
|
|
||||||
if ($previous instanceof ClientAware) {
|
if ($previous instanceof ClientAware) {
|
||||||
$this->isClientSafe = $previous->isClientSafe();
|
$this->isClientSafe = $previous->isClientSafe();
|
||||||
$this->category = $previous->getCategory() ?: static::INTERNAL;
|
$this->category = $previous->getCategory() ?: static::CATEGORY_INTERNAL;
|
||||||
} else if ($previous) {
|
} else if ($previous) {
|
||||||
$this->isClientSafe = false;
|
$this->isClientSafe = false;
|
||||||
$this->category = static::INTERNAL;
|
$this->category = static::CATEGORY_INTERNAL;
|
||||||
} else {
|
} else {
|
||||||
$this->isClientSafe = true;
|
$this->isClientSafe = true;
|
||||||
$this->category = static::GRAPHQL;
|
$this->category = static::CATEGORY_GRAPHQL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,6 +239,17 @@ class Error extends \Exception implements \JsonSerializable, ClientAware
|
|||||||
return $this->locations;
|
return $this->locations;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns an array describing the JSON-path into the execution response which
|
||||||
|
* corresponds to this error. Only included for errors during execution.
|
||||||
|
*
|
||||||
|
* @return array|null
|
||||||
|
*/
|
||||||
|
public function getPath()
|
||||||
|
{
|
||||||
|
return $this->path;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns array representation of error suitable for serialization
|
* Returns array representation of error suitable for serialization
|
||||||
*
|
*
|
||||||
|
@ -24,6 +24,9 @@ class FormattedError
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Standard GraphQL error formatter. Converts any exception to GraphQL error
|
||||||
|
* conforming to GraphQL spec
|
||||||
|
*
|
||||||
* @param \Throwable $e
|
* @param \Throwable $e
|
||||||
* @param bool|int $debug
|
* @param bool|int $debug
|
||||||
* @param string $internalErrorMessage
|
* @param string $internalErrorMessage
|
||||||
@ -56,7 +59,7 @@ class FormattedError
|
|||||||
} else {
|
} else {
|
||||||
$result = [
|
$result = [
|
||||||
'message' => $internalErrorMessage,
|
'message' => $internalErrorMessage,
|
||||||
'category' => Error::INTERNAL
|
'category' => Error::CATEGORY_INTERNAL
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
if (($debug & self::INCLUDE_DEBUG_MESSAGE > 0) && $result['message'] === $internalErrorMessage) {
|
if (($debug & self::INCLUDE_DEBUG_MESSAGE > 0) && $result['message'] === $internalErrorMessage) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user