Laravel 5.5를 사용하고 있습니다. buildExceptionThrowable을 구현하지 않는 객체를 던질 수 없습니다.
있음, Laravel 5.4, 내가 할 수 있었다 : 클래스에게이 업체 \ laravel의 \ 프레임 워크를 분명히 \ 라우팅 \ 미들웨어 \ ThrottleRequests.php이
메서드 이름과\ SRC
\ 다음입니다 아래처럼이 메소드에서 JSON을 리턴한다.
protected function buildException($key, $maxAttempts) { $retryAfter = $this->getTimeUntilNextRetry($key); $headers = $this->getHeaders( $maxAttempts, $this->calculateRemainingAttempts($key, $maxAttempts, $retryAfter), $retryAfter ); return response()->json('429 Too many requests'); }
내가 Laravel 5.5을 사용하여 위의 방법에 JSON을 반환하려고, 그것은
가이 Throwable를 구현하지 않는 객체
이제 있는지, 어떻게 JSON을 반환 할 수 던질 수 없다고 위의 방법에 대한 Laravel 5.5에서
YourCustomException에 대한 예제 (ThrottleRequests 및 Handler.php) 모두 – Pankaj
에 대한 자세한 내용을 제공 할 수 있습니다.'buildfoo' 메서드에서'Symfony \ Component \ HttpKernel \ Exception \ HttpException'을 확장하는 사용자 정의 클래스를 만들 수 있습니다. 예외 및 처리기에서'if ($ e instanceof YourCustomException) {' –