/**
* Constructor.
*
* @param ErrorInterface|ErrorInterface[]|ErrorCollection $errors
* @param int $httpCode
* @param Exception|null $previous
*/
public function __construct($errors, $httpCode = self::DEFAULT_HTTP_CODE, Exception $previous = null)
{
parent::__construct(T::t('JSON API error'), 0, $previous);
$this->errors = new ErrorCollection();
if ($errors instanceof ErrorCollection) {
$this->addErrors($errors);
} elseif (is_array($errors) === true) {
$this->addErrorsFromArray($errors);
} else {
// should be ErrorInterface
$this->addError($errors);
}
$this->httpCode = $httpCode;
}