gformlib.exceptions
Custom exceptions for gformlib.
This module defines the exception hierarchy used throughout the library.
All library-specific exceptions inherit from GFormLibError.
- exception gformlib.exceptions.GFormLibError[source]
Bases:
ExceptionBase exception class for all gformlib errors.
All library-specific exceptions are subclasses of this class, allowing callers to catch any gformlib error with a single
exceptclause:try: client.create_form(config) except GFormLibError as exc: print(f"gformlib error: {exc}")
- exception gformlib.exceptions.AuthenticationError[source]
Bases:
GFormLibErrorRaised when authentication with Google APIs fails.
This may occur when credentials are missing, expired, or lack the required OAuth scopes (
forms.body,drive.file, etc.).Example:
try: client = GoogleFormsClient.from_service_account("creds.json") except AuthenticationError as exc: print(f"Auth failed: {exc}")
- exception gformlib.exceptions.FormCreationError(message, config=None)[source]
Bases:
GFormLibErrorRaised when initial form creation via the API fails.
Wraps errors returned by the
forms().create()call.- config
The form configuration dict that triggered the error.
- exception gformlib.exceptions.FormUpdateError(message, form_id=None)[source]
Bases:
GFormLibErrorRaised when a
batchUpdatecall to add questions fails.- form_id
The form that was being updated when the error occurred.
- exception gformlib.exceptions.InvalidConfigError(message, field=None)[source]
Bases:
GFormLibErrorRaised when the supplied form or question configuration is invalid.
This is a client-side validation error raised before any API call is made.
- field
The configuration field that failed validation (if known).
- exception gformlib.exceptions.APIError(message, status_code=None, details=None)[source]
Bases:
GFormLibErrorRaised when the Google Forms API returns an unexpected HTTP error.
- Parameters:
- Return type:
None
- status_code
HTTP status code returned by the API.
- details
Parsed JSON error body from the API response.