SyntaxError
extends Error
in package
Describes an Error found during the parse, validate, or execute phases of performing a Automattic\WooCommerce\Vendor\GraphQL operation. In addition to a message and stack trace, it also includes information about the locations in a Automattic\WooCommerce\Vendor\GraphQL document and/or execution result that correspond to the Error.
When the error was caused by an exception thrown in resolver, original exception
is available via getPrevious().
Also read related docs on error handling
Class extends standard PHP \Exception, so all standard methods of base \Exception class
are available in addition to those listed below.
Table of Contents
- $nodes : array<string|int, mixed>|null
- An array of Automattic\WooCommerce\Vendor\GraphQL AST Nodes corresponding to this error.
- $path : array<string|int, mixed>|null
- An array describing the JSON-path into the execution response which corresponds to this error. Only included for errors during execution.
- $unaliasedPath : array<string|int, mixed>|null
- An array describing the JSON-path into the execution response which corresponds to this error. Only included for errors during execution.
- $extensions : array<string|int, mixed>|null
- $isClientSafe : bool
- $locations : array<string|int, mixed>
- Lazily initialized.
- $positions : array<string|int, mixed>|null
- $source : Source|null
- The source Automattic\WooCommerce\Vendor\GraphQL document for the first location of this error.
- __construct() : mixed
- __toString() : string
- createLocatedError() : Error
- Given an arbitrary Error, presumably thrown while attempting to execute a Automattic\WooCommerce\Vendor\GraphQL operation, produce a new GraphQLError aware of the location in the document responsible for the original Error.
- getExtensions() : array<string, mixed>|null
- Data to include within the "extensions" key of the formatted error.
- getLocations() : array<int, SourceLocation>
- An array of locations within the source Automattic\WooCommerce\Vendor\GraphQL document which correspond to this error.
- getNodes() : array<string|int, Node>|null
- getPath() : array<int, int|string>|null
- Returns an array describing the path from the root value to the field which produced this error.
- getPositions() : array<int, int>
- getSource() : Source|null
- getUnaliasedPath() : array<int, int|string>|null
- Returns an array describing the path from the root value to the field which produced this error.
- isClientSafe() : bool
- Is it safe to show the error message to clients?
- jsonSerialize() : array<string, mixed>
- Specify data which should be serialized to JSON.
- isLocated() : bool
Properties
$nodes
An array of Automattic\WooCommerce\Vendor\GraphQL AST Nodes corresponding to this error.
public
array<string|int, mixed>|null
$nodes
$path
An array describing the JSON-path into the execution response which corresponds to this error. Only included for errors during execution.
public
array<string|int, mixed>|null
$path
When fields are aliased, the path includes aliases.
$unaliasedPath
An array describing the JSON-path into the execution response which corresponds to this error. Only included for errors during execution.
public
array<string|int, mixed>|null
$unaliasedPath
This will never include aliases.
$extensions
protected
array<string|int, mixed>|null
$extensions
$isClientSafe
private
bool
$isClientSafe
$locations
Lazily initialized.
private
array<string|int, mixed>
$locations
$positions
private
array<string|int, mixed>|null
$positions
$source
The source Automattic\WooCommerce\Vendor\GraphQL document for the first location of this error.
private
Source|null
$source
Note that if this Error represents more than one node, the source may not represent nodes after the first node.
Methods
__construct()
public
__construct(Source $source, int $position, string $description) : mixed
Parameters
- $source : Source
- $position : int
- $description : string
Return values
mixed —__toString()
public
__toString() : string
Return values
string —createLocatedError()
Given an arbitrary Error, presumably thrown while attempting to execute a Automattic\WooCommerce\Vendor\GraphQL operation, produce a new GraphQLError aware of the location in the document responsible for the original Error.
public
static createLocatedError(mixed $error[, iteratable<string|int, Node>|Node|null $nodes = null ][, array<int, int|string>|null $path = null ][, array<int, int|string>|null $unaliasedPath = null ]) : Error
Parameters
- $error : mixed
- $nodes : iteratable<string|int, Node>|Node|null = null
- $path : array<int, int|string>|null = null
- $unaliasedPath : array<int, int|string>|null = null
Return values
Error —getExtensions()
Data to include within the "extensions" key of the formatted error.
public
getExtensions() : array<string, mixed>|null
Return values
array<string, mixed>|null —getLocations()
An array of locations within the source Automattic\WooCommerce\Vendor\GraphQL document which correspond to this error.
public
getLocations() : array<int, SourceLocation>
Each entry has information about line and column within source Automattic\WooCommerce\Vendor\GraphQL document:
$location->line;
$location->column;
Errors during validation often contain multiple locations, for example to point out to field mentioned in multiple fragments. Errors during execution include a single location, the field which produced the error.
Return values
array<int, SourceLocation> —getNodes()
public
getNodes() : array<string|int, Node>|null
Return values
array<string|int, Node>|null —getPath()
Returns an array describing the path from the root value to the field which produced this error.
public
getPath() : array<int, int|string>|null
Only included for execution errors. When fields are aliased, the path includes aliases.
Return values
array<int, int|string>|null —getPositions()
public
getPositions() : array<int, int>
Return values
array<int, int> —getSource()
public
getSource() : Source|null
Return values
Source|null —getUnaliasedPath()
Returns an array describing the path from the root value to the field which produced this error.
public
getUnaliasedPath() : array<int, int|string>|null
Only included for execution errors. This will never include aliases.
Return values
array<int, int|string>|null —isClientSafe()
Is it safe to show the error message to clients?
public
isClientSafe() : bool
Return values
bool —jsonSerialize()
Specify data which should be serialized to JSON.
public
jsonSerialize() : array<string, mixed>
Tags
Return values
array<string, mixed> — data which can be serialized by json_encode, which is a value of any type other than a resourceisLocated()
protected
isLocated() : bool
