Error Handling Rules
Creating Error Handling Rules
use Midnite81\Guardian\Rules\ErrorHandlingRule;
use Midnite81\Guardian\Enums\Interval;
// Allow 5 failures per minute, before throwing an error
$rule1 = ErrorHandlingRule::allowFailures(5)->perMinute();
// Equivalent to $rule1, but with explicit thenThrow()
$rule2 = ErrorHandlingRule::allowFailures(5)->perMinute()->thenThrow();
// Allow 50 failures per hour, without throwing an exception (for monitoring purposes)
$rule3 = ErrorHandlingRule::allowFailures(50)->perHour()->thenThrow(false);
// Allow 100 failures per day, before throwing an error
$rule4 = ErrorHandlingRule::allowFailures(100)->perDay();
// Allow 20 failures every 3 hours, before throwing an error
$rule5 = ErrorHandlingRule::allowFailures(20)->perInterval(Interval::HOUR, 3);Available Methods
Static Factory Method
Time Interval Methods
Expiration Method
Action Method
Getter Methods
The thenThrow() Method
thenThrow() MethodUsing Error Handling Rules
Best Practices
Last updated