From 9fc4126511f514e0bdb11e87bb5a1149a5f663f4 Mon Sep 17 00:00:00 2001 From: Alon Kukliansky Date: Wed, 4 Sep 2024 15:53:24 -0700 Subject: [PATCH] Adding the original exception only in uncommon cases --- bqskit/compiler/compiler.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/bqskit/compiler/compiler.py b/bqskit/compiler/compiler.py index 8f58f3c35..e193a68cd 100644 --- a/bqskit/compiler/compiler.py +++ b/bqskit/compiler/compiler.py @@ -406,7 +406,12 @@ def _send(self, msg: RuntimeMessage, payload: Any) -> None: except Exception as e: self.conn = None self.close() - raise RuntimeError('Server connection unexpectedly closed.') from e + if isinstance(e, (EOFError, ConnectionResetError)): + raise RuntimeError('Server connection unexpectedly closed.') + else: + raise RuntimeError( + 'Server connection unexpectedly closed.', + ) from e def _send_recv( self,