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