class UnprocessableHttpEntityException in JSON:API 8
Same name and namespace in other branches
- 8.2 src/Exception/UnprocessableHttpEntityException.php \Drupal\jsonapi\Exception\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
Hierarchy
- class \Drupal\jsonapi\Exception\UnprocessableHttpEntityException extends \Symfony\Component\HttpKernel\Exception\HttpException uses DependencySerializationTrait
Expanded class hierarchy of UnprocessableHttpEntityException
2 files declare their use of UnprocessableHttpEntityException
- EntityResource.php in src/Controller/ EntityResource.php 
- UnprocessableHttpEntityExceptionNormalizer.php in src/Normalizer/ UnprocessableHttpEntityExceptionNormalizer.php 
File
- src/Exception/ UnprocessableHttpEntityException.php, line 20 
Namespace
Drupal\jsonapi\ExceptionView 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
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| DependencySerializationTrait:: | protected | property | An array of entity type IDs keyed by the property name of their storages. | |
| DependencySerializationTrait:: | protected | property | An array of service IDs keyed by property name used for serialization. | |
| DependencySerializationTrait:: | public | function | 1 | |
| DependencySerializationTrait:: | public | function | 2 | |
| UnprocessableHttpEntityException:: | protected | property | The constraint violations associated with this exception. | |
| UnprocessableHttpEntityException:: | public | function | Gets the constraint violations associated with this exception. | |
| UnprocessableHttpEntityException:: | public | function | Sets the constraint violations associated with this exception. | |
| UnprocessableHttpEntityException:: | public | function | UnprocessableHttpEntityException constructor. | 
