fix: handle uncaught UnicodeDecodeError

UnicodeDecodeError occurred when trying to connect to the server with HTTPS. The error
was not caught by the broad Exception clause in `handle_agent`, causing a traceback
to be dumped.
This commit is contained in:
agatha 2024-09-07 17:09:32 -04:00
parent f71d86fce7
commit 6c0eb7f941

View File

@ -87,6 +87,8 @@ class Server:
conn.send(json.dumps({"command": command}).encode())
except json.decoder.JSONDecodeError:
logger.error(f"Invalid JSON received from {addr}")
except UnicodeDecodeError:
logger.error(f"Invalid UTF-8 received from {addr}")
except Exception as e:
logger.error(f"Error handling agent {agent_id}: {e}")
finally: