klippy_connection: fix error message from Klipper

Signed-off-by:  Eric Callahan <arksine.code@gmail.com>
This commit is contained in:
Eric Callahan 2023-11-05 16:38:16 -05:00
parent 07388f4d38
commit 7337c6f762
No known key found for this signature in database
GPG Key ID: 5A1EB336DFB4C71B
1 changed files with 5 additions and 1 deletions

View File

@ -26,7 +26,8 @@ from typing import (
Dict,
List,
Set,
Tuple
Tuple,
Union
)
if TYPE_CHECKING:
from .server import Server
@ -495,7 +496,10 @@ class KlippyConnection:
result = "ok"
request.set_result(result)
else:
err: Union[str, Dict[str, str]]
err = cmd.get('error', "Malformed Klippy Response")
if isinstance(err, dict):
err = err.get("message", "Malformed Klippy Response")
request.set_exception(ServerError(err, 400))
async def _execute_method(self, method_name: str, **kwargs) -> None: