SAService Architect Back to designer
SAService ArchitectDocumentation
Python DSL reference ServiceArchitectClient | AuthenticationError | CodeGenerationError

Client reuse and errors

Reuse authentication across requests and handle network, API, payload, base64, and archive failures explicitly.

When to use

Use the client directly in automation that generates several projects or needs structured error handling.

Behavior

  • ServiceArchitectClient.from_env() creates a reusable client and caches the temporary ID token in memory after successful authentication.
  • AuthenticationError represents rejected credentials, unsupported challenges, invalid SRP values, and Cognito connectivity failures.
  • CodeGenerationError represents HTTP failures, API error payloads, malformed JSON/base64, and non-ZIP responses.
  • A successful response may be an API Gateway JSON envelope or a direct application/zip body.

Error attributes properties

Structured information preserved by client exceptions.

PropertyTypeDescription
AuthenticationError.detailsany

Cognito response details without deliberately adding credentials.

CodeGenerationError.status_codeint | None

Outer HTTP status or API payload status.

CodeGenerationError.detailsany

Decoded JSON error payload or response text.

Python example

from sa_dsl import AuthenticationError, CodeGenerationError, ServiceArchitectClient

client = ServiceArchitectClient.from_env()
try:
    archive = client.generate_code(project)
except AuthenticationError as error:
    print(f"Authentication failed: {error}")
except CodeGenerationError as error:
    print(f"Generation failed ({error.status_code}): {error}")