Skip to main content
All SDK exceptions extend 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:
  1. Throws NexusBillingException from NexusClient::create or sync().
  2. 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).
The cache stays valid and readable until the process ends. The billing block clears automatically when a subsequent sync() succeeds after the invoice is settled.
The cache is never cleared on a billing error. The last-known-good snapshot continues to be served, which is usually the safe behaviour for running services. Only the refresh loop is suspended.

What is NOT thrown as an exception

  • Background TTL syncs - silently retried. Cache served. Errors are logged via the configured PSR-3 logger at error level.
  • Missing config or flag - getConfig returns $default (or null); getFlag returns $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 when NexusClient::create runs, Guzzle throws a \GuzzleHttp\Exception\ConnectException which is wrapped in a NexusException:

Reading a secret that doesn’t exist