From e028a5236b13cf210f3b3c673e6f82403b990d9c Mon Sep 17 00:00:00 2001 From: viras777 <38958515+viras777@users.noreply.github.com> Date: Mon, 10 Apr 2023 20:22:21 +0300 Subject: [PATCH] Add ability to use otherwise() in connection stage In the function awaitConnectionTune I added interception of all exceptions to be able to process in reject. like this: Connection = (new Client())->connect()->then()->otherwise(); --- src/Bunny/ClientMethods.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/Bunny/ClientMethods.php b/src/Bunny/ClientMethods.php index 48dc8bb..7b23c17 100644 --- a/src/Bunny/ClientMethods.php +++ b/src/Bunny/ClientMethods.php @@ -292,6 +292,9 @@ public function awaitConnectionTune() $deferred->reject(new ClientException($frame->replyText, $frame->replyCode)); }); return true; + } elseif ($frame instanceof \Throwable) { + $deferred->reject(new ClientException($frame->getMessage(), Constants::STATUS_ACCESS_REFUSED)); + return true; } return false; });