Skip to content

Commit

Permalink
adding new type of exception
Browse files Browse the repository at this point in the history
  • Loading branch information
rodolfocarobene committed Apr 14, 2024
1 parent f181d3f commit 4ed84f1
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/qibosoq/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ class QibosoqError(RuntimeError):
"""


class RuntimeLoopError(QibosoqError):
"""Exception raised when qibosoq server encounters a readout loop error.
Attributes:
message -- The error message received from the server (qibosoq)
"""


def connect(server_commands: dict, host: str, port: int) -> Tuple[list, list]:
"""Open a connection with the server and executes the commands."""
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as sock:
Expand All @@ -33,6 +41,8 @@ def connect(server_commands: dict, host: str, port: int) -> Tuple[list, list]:
received.extend(tmp)
results = json.loads(received.decode("utf-8"))
if isinstance(results, str):
if "exception in readout loop":
raise RuntimeLoopError(results)
raise QibosoqError(results)
return results["i"], results["q"]

Expand Down

0 comments on commit 4ed84f1

Please sign in to comment.