CoercionError
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.
Tags
Table of Contents
- $inputPath : array<string|int, mixed>|null
- $invalidValue : mixed
- $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.
- make() : static
- printInputPath() : string|null
- printInvalidValue() : string
- isLocated() : bool
Properties
$inputPath
public
array<string|int, mixed>|null
$inputPath
$invalidValue
public
mixed
$invalidValue
$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([string $message = '' ][, iteratable<array-key, \Automattic\WooCommerce\Vendor\GraphQL\Language\AST\Node|null>|Node|null $nodes = null ][, Source|null $source = null ][, array<int, int>|null $positions = null ][, array<int, int|string>|null $path = null ][, Throwable|null $previous = null ][, array<string, mixed>|null $extensions = null ][, array<int, int|string>|null $unaliasedPath = null ]) : mixed
Parameters
- $message : string = ''
- $nodes : iteratable<array-key, \Automattic\WooCommerce\Vendor\GraphQL\Language\AST\Node|null>|Node|null = null
- $source : Source|null = null
- $positions : array<int, int>|null = null
- $path : array<int, int|string>|null = null
- $previous : Throwable|null = null
- $extensions : array<string, mixed>|null = null
- $unaliasedPath : array<int, int|string>|null = null
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 resourcemake()
public
static make(string $message, InputPath|null $inputPath, mixed $invalidValue[, Throwable|null $previous = null ]) : static
Parameters
- $message : string
- $inputPath : InputPath|null
- $invalidValue : mixed
-
whatever invalid value was passed
- $previous : Throwable|null = null
Return values
static —printInputPath()
public
printInputPath() : string|null
Return values
string|null —printInvalidValue()
public
printInvalidValue() : string
Return values
string —isLocated()
protected
isLocated() : bool
