Skip to content

Commit

Permalink
Merge pull request #5 from laravel-lib/main
Browse files Browse the repository at this point in the history
Add minutes to the Exception
  • Loading branch information
danharrin authored May 17, 2021
2 parents b4bf112 + 794802e commit 5ff0288
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion src/Exceptions/TooManyRequestsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,24 @@ class TooManyRequestsException extends Exception
public $method;

public $secondsUntilAvailable;

public $minutesUntilAvailable;

public function __construct($component, $method, $ip, $secondsUntilAvailable)
{
$this->component = $component;
$this->ip = $ip;
$this->method = $method;
$this->secondsUntilAvailable = $secondsUntilAvailable;
$this->minutesUntilAvailable = ceil($this->secondsUntilAvailable / 60);

parent::__construct(sprintf(
'Too many requests from [%s] to method [%s] on component: [%s]. Retry in %d seconds.',
$this->ip,
$this->method,
$this->component,
$this->secondsUntilAvailable
$this->secondsUntilAvailable,
$this->minutesUntilAvailable
));
}
}

0 comments on commit 5ff0288

Please sign in to comment.