misc_pterodactyl-panel/app/Exceptions/Model/DataValidationException.php

59 lines
1.3 KiB
PHP
Raw Normal View History

<?php
namespace Pterodactyl\Exceptions\Model;
use Illuminate\Contracts\Validation\Validator;
use Pterodactyl\Exceptions\PterodactylException;
use Illuminate\Contracts\Support\MessageProvider;
use Symfony\Component\HttpKernel\Exception\HttpExceptionInterface;
class DataValidationException extends PterodactylException implements HttpExceptionInterface, MessageProvider
{
/**
* The validator instance.
*
* @var \Illuminate\Contracts\Validation\Validator
*/
public $validator;
/**
* DataValidationException constructor.
*/
public function __construct(Validator $validator)
{
parent::__construct(
'Data integrity exception encountered while performing database write operation. ' . $validator->errors()->toJson()
);
$this->validator = $validator;
}
/**
* Return the validator message bag.
*
* @return \Illuminate\Support\MessageBag
*/
public function getMessageBag()
{
return $this->validator->errors();
}
/**
* Return the status code for this request.
*
* @return int
*/
2022-02-27 21:15:11 +00:00
public function getStatusCode(): int
{
return 500;
}
/**
* @return array
*/
2022-02-27 21:15:11 +00:00
public function getHeaders(): array
{
return [];
}
}