Automattic\WooCommerce\Vendor\GraphQL\Error
FormattedError::addDebugEntries
Decorates spec-compliant $formattedError with debug entries according to $debug flags.
Method of the class: FormattedError{}
No Hooks.
Returns
SerializableError.
Usage
$result = FormattedError::addDebugEntries( $formattedError, $e, $debugFlag ): array;
- $formattedError(SerializableError) (required)
- .
- $e(Throwable) (required)
- .
- $debugFlag(int) (required)
- For available flags @see \Automattic\WooCommerce\Vendor\GraphQL\Error\DebugFlag.
FormattedError::addDebugEntries() FormattedError::addDebugEntries code WC 10.9.1
public static function addDebugEntries(array $formattedError, \Throwable $e, int $debugFlag): array
{
if ($debugFlag === DebugFlag::NONE) {
return $formattedError;
}
if (($debugFlag & DebugFlag::RETHROW_INTERNAL_EXCEPTIONS) !== 0) {
if (! $e instanceof Error) {
throw $e;
}
if ($e->getPrevious() !== null) {
throw $e->getPrevious();
}
}
$isUnsafe = ! $e instanceof ClientAware || ! $e->isClientSafe();
if (($debugFlag & DebugFlag::RETHROW_UNSAFE_EXCEPTIONS) !== 0 && $isUnsafe && $e->getPrevious() !== null) {
throw $e->getPrevious();
}
if (($debugFlag & DebugFlag::INCLUDE_DEBUG_MESSAGE) !== 0 && $isUnsafe) {
$formattedError['extensions']['debugMessage'] = $e->getMessage();
}
if (($debugFlag & DebugFlag::INCLUDE_TRACE) !== 0) {
$actualError = $e->getPrevious() ?? $e;
if ($e instanceof \ErrorException || $e instanceof \Error) {
$formattedError['extensions']['file'] = $e->getFile();
$formattedError['extensions']['line'] = $e->getLine();
} else {
$formattedError['extensions']['file'] = $actualError->getFile();
$formattedError['extensions']['line'] = $actualError->getLine();
}
$isTrivial = $e instanceof Error && $e->getPrevious() === null;
if (! $isTrivial) {
$formattedError['extensions']['trace'] = static::toSafeTrace($actualError);
}
}
return $formattedError;
}