Google Tag Manager - v1.0.0

Exceptions

Two exception classes under ArtisanPackUI\GoogleTagManager\Exceptions\.

ApiException

Thrown by TagManagerClient for any failure that comes from either the upstream Tag Manager API or a transport failure on the way there. Fetchers and controllers let it bubble.

$status: ?int

Public readonly property. Holds the HTTP status code from the upstream response, or null when the failure was purely transport (network error, DNS failure, etc.) or configuration (missing connection, missing config key).

Useful for 404 detection specifically — the raw exception message is translated through Laravel's HTTP client and may not include the status code otherwise.

try {
    $client->listContainers( $connection, $accountId );
} catch ( \ArtisanPackUI\GoogleTagManager\Exceptions\ApiException $e ) {
    if ( 404 === $e->status ) {
        // account doesn't exist
    } elseif ( 403 === $e->status ) {
        // Tag Manager API not enabled, or user has no access
    } else {
        // transport, config, or unknown
    }
}

Named constructors

The class ships static factory methods for the common cases; callers rarely construct one directly:

  • ApiException::apiError( int $status, string $body ) — upstream API returned a non-2xx response
  • ApiException::authenticationFailed( Throwable $previous ) — wraps a TokenRefreshException from the base package, so a single catch ( ApiException $e ) covers OAuth failures too
  • ApiException::transportFailure( Throwable $previous ) — network / DNS / timeout
  • ApiException::missingConfiguration( string $key ) — a required config key is missing
  • ApiException::missingConnection() — no GoogleConnection was resolved for the request
  • ApiException::unknownWorkspace( string $workspaceId ) — caller-supplied workspace ID is not in the container

BaseNotInstalledException

Thrown by TagManagerClient when either the base artisanpack-ui/google package is missing entirely, or the TokenManager singleton is not bound. Callers should either:

  • Feature-detect via TagManagerClient::isAvailable() before calling, OR
  • Feature-detect via GoogleTagManager::hasApi() before resolving the client at all

The controllers translate this to a 501 Not Implemented response.