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 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 snapshot at error level. Rejected credentials, a suspended account, a missing service and an unrenewable WIF session are raised instead.
  • 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, 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:

Reading a secret that doesn’t exist