Skip to main content

Exception hierarchy

Import exceptions from simulacrum.exceptions as needed. All SDK-specific errors subclass SimulacrumError.
ExceptionDescription
SimulacrumErrorBase class; catch when you want to handle all SDK errors.
AuthErrorAuthentication failed (covers invalid, inactive, or expired keys).
ApiKeyInvalidErrorAPI key is unknown to the platform.
ApiKeyInactiveErrorAPI key has been disabled administratively.
ApiKeyExpiredErrorAPI key has passed its expiration timestamp.
QuotaExceededErrorRequest rejected because you exceeded usage limits.
ForecastAlreadyRunningErrorThe same forecast job is currently in progress.
InvalidRequestErrorPayload failed server-side validation.
ApiErrorGeneric API or parsing failure.

Usage patterns

from simulacrum.exceptions import (
    AuthError,
    ForecastAlreadyRunningError,
    QuotaExceededError,
    SimulacrumError,
)

try:
    forecast = client.forecast(series, horizon=12)
except AuthError:
    rotate_key()
except ForecastAlreadyRunningError:
    wait_for_job()
except QuotaExceededError:
    backoff()
except SimulacrumError as exc:
    log_error("Unhandled Simulacrum error", error=exc)
    raise
The ERROR_CODE_MAP constant inside the module surfaces the mapping between API error_code values and exception classes. Extend your handlers as new codes are introduced.