From 99c2fb79d7c4d2500f9c489bf31f02ff928c70a3 Mon Sep 17 00:00:00 2001 From: paul2212 Date: Sat, 7 Mar 2026 13:50:51 +0100 Subject: [PATCH] fix error 500 --- fichero/api.py | 2 +- fichero/printer.py | 10 ++++++++++ fichero_printer/config.yaml | 2 +- fichero_printer/fichero/api.py | 2 +- fichero_printer/fichero/printer.py | 10 ++++++++++ 5 files changed, 23 insertions(+), 3 deletions(-) diff --git a/fichero/api.py b/fichero/api.py index 9af0940..d191d8a 100644 --- a/fichero/api.py +++ b/fichero/api.py @@ -95,7 +95,7 @@ def _address(address: str | None) -> str | None: @app.get("/", include_in_schema=False) async def root(): """Redirect root to interactive API docs.""" - return RedirectResponse(url="/docs") + return RedirectResponse(url="docs") @app.get( diff --git a/fichero/printer.py b/fichero/printer.py index 446d7ad..1fbf137 100644 --- a/fichero/printer.py +++ b/fichero/printer.py @@ -162,6 +162,16 @@ class RFCOMMClient: loop.sock_connect(sock, (self._address, self._channel)), timeout=10.0, ) + except asyncio.TimeoutError as exc: + sock.close() + raise PrinterTimeout( + f"Classic Bluetooth connection timed out to {self._address} (channel {self._channel})." + ) from exc + except OSError as exc: + sock.close() + raise PrinterError( + f"Classic Bluetooth connection failed for '{self._address}' (channel {self._channel}): {exc}" + ) from exc except Exception: sock.close() raise diff --git a/fichero_printer/config.yaml b/fichero_printer/config.yaml index f83f967..6d22711 100644 --- a/fichero_printer/config.yaml +++ b/fichero_printer/config.yaml @@ -18,7 +18,7 @@ ingress: true ingress_port: 8765 panel_icon: mdi:printer panel_title: Fichero Printer -webui: "http://[HOST]:[PORT:8765]/docs" +webui: "http://[HOST]:[PORT:8765]/" host_network: true host_dbus: true diff --git a/fichero_printer/fichero/api.py b/fichero_printer/fichero/api.py index 9af0940..d191d8a 100644 --- a/fichero_printer/fichero/api.py +++ b/fichero_printer/fichero/api.py @@ -95,7 +95,7 @@ def _address(address: str | None) -> str | None: @app.get("/", include_in_schema=False) async def root(): """Redirect root to interactive API docs.""" - return RedirectResponse(url="/docs") + return RedirectResponse(url="docs") @app.get( diff --git a/fichero_printer/fichero/printer.py b/fichero_printer/fichero/printer.py index 446d7ad..1fbf137 100644 --- a/fichero_printer/fichero/printer.py +++ b/fichero_printer/fichero/printer.py @@ -162,6 +162,16 @@ class RFCOMMClient: loop.sock_connect(sock, (self._address, self._channel)), timeout=10.0, ) + except asyncio.TimeoutError as exc: + sock.close() + raise PrinterTimeout( + f"Classic Bluetooth connection timed out to {self._address} (channel {self._channel})." + ) from exc + except OSError as exc: + sock.close() + raise PrinterError( + f"Classic Bluetooth connection failed for '{self._address}' (channel {self._channel}): {exc}" + ) from exc except Exception: sock.close() raise