Database/src/Exceptions/Query/NoPrimaryFieldException.php

22 lines
707 B
PHP

<?php
namespace Nest\Database\Exceptions\Query;
use Nest\Model\Entity;
use Throwable;
/**
* Exception thrown when an entity has no primary fields to use in WHERE clause.
*/
class NoPrimaryFieldException extends QueryBuilderException
{
/**
* @param Entity $entity The entity without primary fields.
* @param int $code [optional] The Exception code.
* @param null|Throwable $previous [optional] The previous throwable used for the exception chaining.
*/
public function __construct(public Entity $entity, int $code = 0, ?Throwable $previous = null)
{
parent::__construct("No defined primary fields for ".get_class($this->entity).", cannot apply WHERE clause on it.", $code, $previous);
}
}