IdentifierCannotBeEmptyException
Overview
IdentifierCannotBeEmptyException
is a custom exception class in the Midnite81\Guardian package. This exception is thrown when an attempt is made to set an empty identifier in the Guardian system.
Class Details
Namespace:
Midnite81\Guardian\Exceptions
Extends:
Exception
Purpose
The primary purpose of this exception is to ensure that valid, non-empty identifiers are always used within the Guardian system. Identifiers are crucial for distinguishing between different rate-limited resources or actions. Guardian does not allow for empty identifiers and will throw this exception.
Usage
This exception is typically thrown by the Guardian system when setting or updating an identifier. It's most commonly encountered in the Guardian
class constructor or when using the setIdentifier
method.
Example of where this exception might be thrown:
Best Practices
Always provide a non-empty string as an identifier when creating a new Guardian instance or setting an identifier.
Catch this exception when there's a possibility of receiving an empty identifier from user input or external sources.
Provide meaningful identifiers that represent the resource or action being rate-limited.
Error Message
The default error message for this exception is:
Handling the Exception
When catching this exception, you should handle it by either:
Providing a default identifier
Logging the error
Notifying the user or system administrator about the invalid input
Example:
Integration with Guardian
This exception is an integral part of the Guardian system's input validation. It ensures that the system always operates with valid identifiers, which is crucial for maintaining the integrity of rate limiting rules across different resources or actions.
Last updated