Laravel 5.2에서 사용자 지정 예외 클래스를 만들었습니다. 그것은 laravel 5.4까지 잘 작동합니다.laravel : App Exceptions CustomException :: report()에 전달 된 인수 1은 Exception의 인스턴스 여야합니다.
동일한 사용자 정의 예외 클래스를 laravel 5.5와 함께 사용하려고하면 다음 오류가 발생합니다. 여기
Type error: Argument 1 passed to App\Utility\Exceptions\CustomException::report() must be an instance of Exception, none given, called in /var/www/html/bubbles/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php on line 102 {"exception":"[object] (Symfony\\Component\\Debug\\Exception\\FatalThrowableError(code: 0): Type error: Argument 1 passed to App\\Utility\\Exceptions\\CustomException::report() must be an instance of Exception, none given, called in /var/www/html/bubbles/vendor/laravel/framework/src/Illuminate/Foundation/Exceptions/Handler.php on line 102 at /var/www/html/bubbles/app/Utility/Exceptions/CustomException.php:39)
내가 그것을 예외의 인스턴스 여야합니다 인수를 던지는 이유 누군가가 나를 설명 할 것입니다 수
<?php
namespace App\Utility\Exceptions;
use Illuminate\Support\Facades\Lang;
use Exception;
class CustomException extends Exception
{
private $error_code = NULL;
private $error_info = NULL;
function __construct($type = NULL, $errors = NULL)
{
$this->error_code = $type['error_code'];
$this->error_info = $errors;
$message = Lang::get('exceptions.'.$this->error_code);
parent::__construct($message, $type['code'], NULL);
}
public function report(Exception $exception)
{
parent::report($exception);
}
public function getErrorCode()
{
return $this->error_code;
}
public function getErrorInfo()
{
return $this->error_info;
}
}
// end of class CustomException
// end of file CustomException.php
를 사용하고 사용자 정의 예외 클래스? 어떤 도움이라도 대단히 감사하겠습니다.
내 프로그래밍 환경 PHP 7.0.1 Laravel 5.5
감사합니다. @ 시셔. 이제 그것은 매력처럼 작동합니다 :) – lakshmaji