RulePreventsExecutionException
Last updated
public function getPreventingRule(): ?RateLimitRuleprotected function getErrorMessageFromRule(): stringuse Midnite81\Guardian\Exceptions\RulePreventsExecutionException;
try {
// Your Guardian-protected code here
} catch (RulePreventsExecutionException $e) {
$rule = $e->getPreventingRule();
if ($rule) {
echo "Request blocked. Rate limit: {$rule->getLimit()} requests per {$rule->getDuration()} {$rule->getInterval()->value}.";
} else {
echo "Request blocked by an unspecified rule.";
}
}Cannot execute the request. Rate limit exceeded: X requests per Y [interval].Cannot execute the request because a rule prevents it.