Skip to content

Commit

Permalink
Return exception instead.
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmichot committed Jul 4, 2017
1 parent 990326c commit 45bfce0
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Illuminate/Routing/Middleware/ThrottleRequests.php
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ public function __construct(RateLimiter $limiter)
* @param int|string $maxAttempts
* @param float|int $decayMinutes
* @return mixed
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
*/
public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes = 1)
{
Expand All @@ -46,7 +47,7 @@ public function handle($request, Closure $next, $maxAttempts = 60, $decayMinutes
$maxAttempts = $this->resolveMaxAttempts($request, $maxAttempts);

if ($this->limiter->tooManyAttempts($key, $maxAttempts, $decayMinutes)) {
$this->buildException($key, $maxAttempts);
throw $this->buildException($key, $maxAttempts);
}

$this->limiter->hit($key, $decayMinutes);
Expand Down Expand Up @@ -100,8 +101,7 @@ protected function resolveRequestSignature($request)
*
* @param string $key
* @param int $maxAttempts
* @return void
* @throws \Symfony\Component\HttpKernel\Exception\HttpException
* @return \Symfony\Component\HttpKernel\Exception\HttpException
*/
protected function buildException($key, $maxAttempts)
{
Expand All @@ -113,7 +113,7 @@ protected function buildException($key, $maxAttempts)
$retryAfter
);

throw new HttpException(429, 'Too Many Attempts.', null, $headers);
return new HttpException(429, 'Too Many Attempts.', null, $headers);
}

/**
Expand Down

0 comments on commit 45bfce0

Please sign in to comment.