webcam-micro 0.2.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,31 @@
1
+ """Structured error-reporting helpers for webcam-micro."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from dataclasses import dataclass
6
+
7
+
8
+ class WebcamMicroError(Exception):
9
+ """Base class for typed, user-facing webcam-micro failures."""
10
+
11
+
12
+ @dataclass(frozen=True)
13
+ class ErrorReport:
14
+ """Describe one user-facing error and its diagnostic text."""
15
+
16
+ error_type: str
17
+ display_message: str
18
+ diagnostic_message: str
19
+
20
+
21
+ def build_error_report(error: BaseException) -> ErrorReport:
22
+ """Return structured notice and diagnostic text for one error."""
23
+
24
+ error_type = error.__class__.__name__
25
+ display_message = str(error).strip() or error_type
26
+ diagnostic_message = f"{error_type}: {display_message}"
27
+ return ErrorReport(
28
+ error_type=error_type,
29
+ display_message=display_message,
30
+ diagnostic_message=diagnostic_message,
31
+ )
@@ -0,0 +1,28 @@
1
+ """Public launcher that prepares the runtime before starting the app."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import sys
6
+ from typing import Sequence
7
+
8
+ from webcam_micro.error_reporting import WebcamMicroError, build_error_report
9
+ from webcam_micro.runtime_bootstrap import bootstrap_runtime
10
+
11
+
12
+ def _run_app(argv: Sequence[str]) -> int:
13
+ """Import the GUI entrypoint lazily after the runtime is ready."""
14
+
15
+ from webcam_micro.app import main as app_main
16
+
17
+ return app_main(argv)
18
+
19
+
20
+ def main(argv: Sequence[str] | None = None) -> int:
21
+ """Bootstrap the runtime interpreter and then start the application."""
22
+
23
+ argv_list = list(sys.argv[1:] if argv is None else argv)
24
+ try:
25
+ bootstrap_runtime(argv_list)
26
+ except WebcamMicroError as exc:
27
+ raise SystemExit(build_error_report(exc).display_message) from exc
28
+ return _run_app(argv_list)