2018-03-24 06:29:54 +08:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Exceptions;
|
|
|
|
|
|
|
|
use Illuminate\Validation\ValidationException;
|
|
|
|
use Log;
|
2018-08-27 00:40:04 +08:00
|
|
|
use Validator;
|
2018-03-24 06:29:54 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
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.
|
2018-08-27 00:40:04 +08:00
|
|
|
*
|
2018-03-24 06:29:54 +08:00
|
|
|
* @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);
|
|
|
|
}
|
|
|
|
}
|