Exception Reference
Both classes live in namespace BioTime\Exceptions;.
ApiException
php
class ApiException extends \RuntimeException
{
public function __construct(
string $message,
protected int $statusCode = 0,
?string $responseBody = null,
?Throwable $previous = null
);
public function getStatusCode(): int;
public function getResponseBody(): ?string;
}Thrown by Client::send() and Client::download() for any response with an HTTP status >= 400, after the automatic 401-retry (see Authentication) has already been attempted.
AuthenticationException
php
class AuthenticationException extends ApiException
{
}Adds no new behavior or properties beyond ApiException — it exists purely so you can catch authentication failures separately with a catch (AuthenticationException $e) block before a broader catch (ApiException $e). Thrown by:
Client::rawRequest()— when the underlying Guzzle request itself throws aGuzzleException(network failure, DNS failure, timeout, etc.), for any request, not only authentication calls.TokenManager::authenticate()— when thePOST /api-token-auth/call fails outright, returns a non-2xx status, or returns a body without atokenfield.
See Error Handling for complete catch examples.