Skip to content

Handle errors

pyventim raises typed exceptions that you can catch individually or as a group.

Exception hierarchy

PyventimError
├── PyventimPublicError
│   └── PyventimPublicPaginationError
└── PyventimPrivateError
    └── PyventimPrivateComponentPaginationError
        ├── PyventimPrivateComponentPaginationHTMLParsingError
        ├── PyventimPrivateComponentPaginationJSONParsingError
        └── PyventimPrivateComponentPaginationJSONKeyError

Catch all pyventim errors

from pyventim import EventimClient, EventimMarket, PyventimError

client = EventimClient(EventimMarket.GERMANY)

try:
    for pg in client.product_groups(categories=["Concerts"], page_limit=1):
        print(pg.name)
except PyventimError as e:
    print(f"pyventim error: {e}")

Catch specific errors

from pyventim import (
    EventimClient,
    EventimMarket,
    PyventimPublicPaginationError,
    PyventimPrivateComponentPaginationHTMLParsingError,
)

client = EventimClient(EventimMarket.GERMANY)

try:
    for event in client.products(product_group_id=99999, page_limit=1):
        print(event.name)
except PyventimPrivateComponentPaginationHTMLParsingError:
    print("Could not parse the event page — Eventim may have changed its layout.")
except PyventimPublicPaginationError as e:
    print(f"Public API pagination failed: {e}")

Notes

  • All exceptions are importable directly from pyventim.
  • PyventimPrivateComponentPaginationError is the parent of all private API pagination errors — catch it to handle any scraping failure without caring about the exact cause.
  • Private API errors are more likely to occur in the wild because they involve HTML scraping.