UI Exceptions¶
Exceptions for the UI module: panels, tables, and spinners.
Exception hierarchy¶
RuntimeError
├── PanelRenderingError # Panel preset or payload invalid
├── TableRenderingError # Table construction failed
└── SpinnerError # Spinner encountered an error
Common failure modes¶
PanelRenderingErroris raised when thePanelManagercannot resolve a preset or when override values are invalid.TableRenderingErrorsurfaces when table construction fails (invalid column config, incompatible data).SpinnerErrormay be raised if the spinner encounters terminal issues or invalid configuration.
Usage patterns¶
Safe panel rendering¶
from kstlib.ui import PanelManager
from kstlib.ui.exceptions import PanelRenderingError
pm = PanelManager()
try:
panel = pm.render("info", content="Status OK", title="Health")
except PanelRenderingError as e:
# Fallback to plain text
print(f"[INFO] Status OK")
Handling table errors¶
from kstlib.ui.tables import TableBuilder
from kstlib.ui.exceptions import TableRenderingError
try:
table = TableBuilder(columns=["Name", "Value"]).add_rows(data).build()
except TableRenderingError as e:
logger.warning(f"Table render failed: {e}")
API reference¶
Specialised exceptions raised by the kstlib.ui helpers.
- exception kstlib.ui.exceptions.PanelRenderingError[source]
Bases:
KstlibError,RuntimeErrorRaised when building a Rich panel fails.
The error captures situations where the
PanelManagercannot resolve the requested preset, where override values are invalid, or when the payload cannot be converted into a Rich renderable.
- exception kstlib.ui.exceptions.SpinnerError[source]
Bases:
KstlibError,RuntimeErrorRaised when the spinner encounters an error.
- exception kstlib.ui.exceptions.TableRenderingError[source]
Bases:
KstlibError,RuntimeErrorRaised when building a Rich table fails.