phpvms/app/Exceptions/InternalError.php

37 lines
896 B
PHP
Raw Normal View History

<?php
namespace App\Exceptions;
use Illuminate\Support\Facades\Log;
use Illuminate\Support\Facades\Validator;
use Illuminate\Validation\ValidationException;
/**
* 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
{
public const FIELD = 'internal_error_message';
public const MESSAGE = '';
/**
* InternalError constructor.
2018-08-27 00:40:04 +08:00
*
* @param string|null $message
* @param null $field
*/
public function __construct(string $message = null, $field = null)
{
Log::error($message);
$validator = Validator::make([], []);
$validator->errors()->add(
$field ?? static::FIELD,
2019-05-13 02:26:44 +08:00
$message ?? static::MESSAGE
);
parent::__construct($validator);
}
}