2018-03-24 06:29:54 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Exceptions;
|
|
|
|
|
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
use Validator;
|
|
|
|
use Log;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Show an internal error, bug piggyback off of the validation
|
|
|
|
* exception type - this has a place to show up in the UI as a
|
|
|
|
* flash message.
|
|
|
|
* @package App\Exceptions
|
|
|
|
*/
|
|
|
|
class InternalError extends ValidationException
|
|
|
|
{
|
2018-03-31 00:08:53 +08:00
|
|
|
public const FIELD = 'internal_error_message';
|
|
|
|
public const MESSAGE = '';
|
2018-03-24 06:29:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* InternalError constructor.
|
|
|
|
* @param string|null $message
|
|
|
|
* @param null $field
|
|
|
|
*/
|
2018-03-31 00:08:53 +08:00
|
|
|
public function __construct(string $message = null, $field = null)
|
2018-03-24 06:29:54 +08:00
|
|
|
{
|
|
|
|
Log::error($message);
|
|
|
|
$validator = Validator::make([], []);
|
2018-03-31 00:08:53 +08:00
|
|
|
$validator->errors()->add(
|
|
|
|
$field ?? static::FIELD,
|
|
|
|
$message ?? static::MESSAGE);
|
2018-03-24 06:29:54 +08:00
|
|
|
|
|
|
|
parent::__construct($validator);
|
|
|
|
}
|
|
|
|
}
|