Copied!

IbexaError

IbexaError.php : 34
Final
Extends Error
Implements HttpExceptionInterface

RFC 7807 error of the v3 API: API Platform's error members plus a stable machine "code", the "localizedMessage" and, for validation errors, the "violations".

Like API Platform's own ValidationException, it is an error resource itself, so the error listener takes the status and the output format from its operations. It is not readonly: it is an exception extending a class with setters.

It also implements Symfony's HttpExceptionInterface (API Platform's own interface is a different one), so Symfony's error listener logs mapped 4xx errors below critical and Monolog's excluded_http_codes can filter them.

Attributes
#[ErrorResource]
$uriVariables: ['status']
$requirements: ['status' => '\d+']
$uriTemplate: '/errors/{status}'
$openapi: false
$operations: [new \ApiPlatform\Metadata\Error(name: '_api_ibexa_errors_problem', outputFormats: ['jsonproblem' => ['application/problem+json']], hideHydraOperation: true, normalizationContext: [\ApiPlatform\JsonSchema\SchemaFactory::OPENAPI_DEFINITION_NAME => '', 'groups' => ['jsonproblem'], 'skip_null_values' => true, 'ignored_attributes' => ['trace', 'file', 'line', 'code', 'message', 'traceAsString', 'previous']]), new \ApiPlatform\Metadata\Error(name: '_api_ibexa_errors_hydra', outputFormats: ['jsonld' => ['application/ld+json']], hideHydraOperation: true, links: [new \Symfony\Component\WebLink\Link(rel: 'http://www.w3.org/ns/json-ld#error', href: 'http://www.w3.org/ns/hydra/error')], normalizationContext: [\ApiPlatform\JsonSchema\SchemaFactory::OPENAPI_DEFINITION_NAME => '', 'groups' => ['jsonld'], 'skip_null_values' => true, 'ignored_attributes' => ['trace', 'file', 'line', 'code', 'message', 'traceAsString', 'previous']])]
$provider: 'ibexa.api_platform.state.error_provider'
$graphQlOperations: []
$description: 'A representation of Ibexa Repository errors.'

Properties

public $errorCode read-only

IbexaError.php : 72
public string $errorCode
Attributes
#[ApiProperty]
$writable: false
$initializable: false
$description: 'A stable machine-readable identifier of the problem.'
#[Groups]
['jsonld', 'jsonproblem']
#[SerializedName]
'code'

public $localizedMessage read-only

IbexaError.php : 77
public string $localizedMessage
Attributes
#[ApiProperty]
$writable: false
$initializable: false
$description: 'The message translated to the language of the request.'
#[Groups]
['jsonld', 'jsonproblem']

public $violations read-only

IbexaError.php : 93
public array<string|int, mixed>|null $violations = null
Attributes
#[ApiProperty]
$writable: false
$initializable: false
$description: 'The violations of a validation error.'
$schema: ['type' => ['array', 'null'], 'items' => ['type' => 'object', 'properties' => ['propertyPath' => ['type' => 'string'], 'message' => ['type' => 'string']], 'required' => ['propertyPath', 'message']]]
#[Groups]
['jsonld', 'jsonproblem']

Methods

public__construct()

IbexaError.php : 87

The code and the localized message are optional because API Platform's error provider instantiates the resource with a title, a detail and a status only, when `/errors/{status}` is requested directly.

public __construct(string $title, string $detail, int $status[, string|null $errorCode = null ][, string|null $localizedMessage = null ][, array<int, array{propertyPath: string, message: string}>|null $violations = null ][, Throwable|null $previous = null ])

Parameters

Name Type Default value Description
$title string - -
$detail string - -
$status int - -
$errorCode string|null null -
$localizedMessage string|null null -
$violations array<int, array{propertyPath: string, message: string}>|null null -
$previous Throwable|null null -

publicfromException()

IbexaError.php : 121
public static fromException(Throwable $exception, int $status, string $code, string $localizedMessage[, array<int, array{propertyPath: string, message: string}>|null $violations = null ]) : self

Parameters

Name Type Default value Description
$exception Throwable - -
$status int - -
$code string - -
$localizedMessage string - -
$violations array<int, array{propertyPath: string, message: string}>|null null -

Return values

self