WestyxNexus\Exceptions\NexusException which itself extends \RuntimeException. This means you can catch the base class to handle any SDK error, or catch specific subclasses for fine-grained control.
Exception hierarchy
Imports
Catching exceptions
Basic pattern
Handling rate limits
NexusRateLimitedException carries an optional $retryAfterSeconds property parsed from the Retry-After response header:
Handling quarantine
NexusQuarantinedException is thrown when the backend returns a 429 with a quarantine body. The service is blocked until the quarantine expires:
Reading a secret with a public key
NexusPublicKeyException fires synchronously before any network call:
402 Payment Required - NexusBillingException
When the backend returns HTTP 402 (the tenant has at least one invoice overdue by more than 14 days), the SDK:
- Throws
NexusBillingExceptionfromNexusClient::createorsync(). - Halts the background sync loop - read methods continue to serve the last cached snapshot (or the empty cache if billing was overdue on first connect).
sync() succeeds after the invoice is settled.
The snapshot is never cleared, but a
402 is raised rather than served from cache: a suspended account is a condition the application has to see. Reads raise NexusBillingException until billing is resolved, at which point the next sync succeeds normally - nothing latches.What is NOT thrown as an exception
- TTL-triggered syncs - a transient failure is retried and the last known snapshot is served, logged as
nexus: refresh failed, serving the cached snapshotaterrorlevel. Rejected credentials, a suspended account, a missing service and an unrenewable WIF session are raised instead. - Missing config or flag -
getConfigreturns$default(ornull);getFlagreturns$default. 304 Not Modified- treated as success; TTL reset.- SSE transport errors inside
connectStream()- logged and counted toward$maxErrors; method returns normally when the limit is reached.
The asymmetry between secrets (return
null) and configs/flags (return default) is deliberate: a missing secret often means misconfiguration, while a missing flag almost always means “use the safe default and continue”.Failure scenarios
Wrong API key
Network down at startup
If the Nexus backend is unreachable whenNexusClient::create runs, the PSR-18 client raises a Psr\Http\Client\ClientExceptionInterface, which the SDK wraps in a NexusException - so you catch one exception type whichever client is in use:
