All custom exceptions extend JOOservices\UserAgent\Exceptions\UserAgentException.
- UserAgentException — base for all library exceptions.
- InvalidSpecException — invalid spec data (version, channel, arch, locale, combination, etc.).
- NoCandidateException — no browser template matches the spec after filtering.
- GenerationPolicyException — policy violations (e.g. unique retries exhausted, invalid
recent()age). - InvalidDatasetException — invalid dataset or catalog data.
- ProviderException — provider/backend errors.
Source: src/Exceptions/InvalidSpecException.php
Raised by SpecValidator and SpecCapabilities for invalid spec data, including:
- invalid version ranges and bounds
- invalid channel/arch/locale/tag
- invalid randomSpec values
- invalid (browser, device, OS) combination (e.g. Safari + Windows): use
invalidCombination()with optionalrequestedSpec,reason, andclosestValidAlternativesfrom the validity matrix
Optional structured fields (when using invalidCombination() or extended factories): getRequestedSpec(), getReason(), getClosestValidAlternatives().
Source: src/Exceptions/NoCandidateException.php
Raised when no browser template candidate can satisfy filters (e.g. from UserAgentBuilder::resolveSpec()).
Optional: getClosestValidAlternatives() returns up to 3 suggested valid (browser, device, OS) combinations when provided via fromFilters($reason, $alternatives).
Source: src/Exceptions/GenerationPolicyException.php
Raised by UserAgentBuilder for policy violations:
- Unique retries exhausted — unique mode could not produce a new UA within the retry limit (
uniqueRetriesExhausted()). - Invalid recent age —
recent($months)was used with an unsupported value (invalidRecentAge()).
Source: src/Facade/UserAgentBuilder.php
LogicExceptionwhentoSpec()is called while bot type is set (usegenerate()for bot UAs).GenerationPolicyExceptionwhen unique retries are exhausted or recent age is invalid (see above).
Source: src/UserAgent.php
UserAgent::__callStatic()throws when fluent static method does not exist onUserAgentBuilder.