Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. UnprocessableHttpEntityException.php

class UnprocessableHttpEntityException

A class to represent a 422 - Unprocessable Entity Exception.

The HTTP 422 status code is used when the server sees:-

The content type of the request is correct. The syntax of the request is correct. BUT was unable to process the contained instruction.

@internal JSON:API maintains no PHP API. The API is the HTTP API. This class may change at any time and could break any dependencies on it.

Hierarchy

  • class \Symfony\Component\HttpKernel\Exception\HttpException extends \Symfony\Component\HttpKernel\Exception\RuntimeException implements \Symfony\Component\HttpKernel\Exception\HttpExceptionInterface
    • class \Drupal\jsonapi\Exception\UnprocessableHttpEntityException extends \Symfony\Component\HttpKernel\Exception\HttpException uses \Drupal\Core\DependencyInjection\DependencySerializationTrait

Expanded class hierarchy of UnprocessableHttpEntityException

See also

https://www.drupal.org/project/drupal/issues/3032787

jsonapi.api.php

2 files declare their use of UnprocessableHttpEntityException
EntityValidationTrait.php in core/modules/jsonapi/src/Entity/EntityValidationTrait.php
UnprocessableHttpEntityExceptionNormalizer.php in core/modules/jsonapi/src/Normalizer/UnprocessableHttpEntityExceptionNormalizer.php

File

core/modules/jsonapi/src/Exception/UnprocessableHttpEntityException.php, line 24

Namespace

Drupal\jsonapi\Exception
View source
class UnprocessableHttpEntityException extends HttpException {
    use DependencySerializationTrait;
    
    /**
     * The constraint violations associated with this exception.
     *
     * @var \Drupal\Core\Entity\EntityConstraintViolationListInterface
     */
    protected $violations;
    
    /**
     * UnprocessableHttpEntityException constructor.
     *
     * @param \Exception|null $previous
     *   The pervious error, if any, associated with the request.
     * @param array $headers
     *   The headers associated with the request.
     * @param int $code
     *   The HTTP status code associated with the request. Defaults to zero.
     */
    public function __construct(?\Exception $previous = NULL, array $headers = [], $code = 0) {
        parent::__construct(422, "Unprocessable Entity: validation failed.", $previous, $headers, $code);
    }
    
    /**
     * Gets the constraint violations associated with this exception.
     *
     * @return \Drupal\Core\Entity\EntityConstraintViolationListInterface
     *   The constraint violations.
     */
    public function getViolations() {
        return $this->violations;
    }
    
    /**
     * Sets the constraint violations associated with this exception.
     *
     * @param \Drupal\Core\Entity\EntityConstraintViolationListInterface $violations
     *   The constraint violations.
     */
    public function setViolations(EntityConstraintViolationListInterface $violations) {
        $this->violations = $violations;
    }

}

Members

Title Sort descending Modifiers Object type Summary Overriden Title Overrides
DependencySerializationTrait::$_entityStorages protected property
DependencySerializationTrait::$_serviceIds protected property
DependencySerializationTrait::__sleep public function 1
DependencySerializationTrait::__wakeup public function 2
HttpException::fromStatusCode public static function
HttpException::getHeaders public function Returns response headers. Overrides HttpExceptionInterface::getHeaders
HttpException::getStatusCode public function Returns the status code. Overrides HttpExceptionInterface::getStatusCode
HttpException::setHeaders public function
UnprocessableHttpEntityException::$violations protected property The constraint violations associated with this exception.
UnprocessableHttpEntityException::getViolations public function Gets the constraint violations associated with this exception.
UnprocessableHttpEntityException::setViolations public function Sets the constraint violations associated with this exception.
UnprocessableHttpEntityException::__construct public function UnprocessableHttpEntityException constructor. Overrides HttpException::__construct

API Navigation

  • Drupal Core 11.1.x
  • Topics
  • Classes
  • Functions
  • Constants
  • Globals
  • Files
  • Namespaces
  • Deprecated
  • Services
RSS feed
Powered by Drupal