Skip to content

Commit

Permalink
Update: Suppress unnecessary exceptions
Browse files Browse the repository at this point in the history
  • Loading branch information
cclilshy committed Oct 31, 2024
1 parent 85eb332 commit 545d8eb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
3 changes: 1 addition & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,7 @@
"ext-zlib": "For better compression",
"cloudtay/ripple-http": "For better http client",
"cloudtay/ripple-websocket": "For better websocket client",
"cloudtay/ripple-mysql": "For better mysql client",
"cloudtay/ripple-guzzle": "For better guzzle client"
"cloudtay/ripple-rdo": "For better mysql client"
},
"minimum-stability": "dev",
"prefer-stable": true
Expand Down
11 changes: 5 additions & 6 deletions src/Coroutine.php
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,6 @@ public static function resume(EventLoop\Suspension $suspension, mixed $result =
}
} catch (EscapeException $exception) {
Coroutine::getInstance()->handleEscapeException($exception);
} catch (FiberError $exception) {
throw $exception;
} catch (Throwable $exception) {
$suspension instanceof Suspension && $suspension->reject($exception);
throw $exception;
}

return null;
Expand Down Expand Up @@ -306,9 +301,13 @@ public static function suspend(EventLoop\Suspension $suspension): mixed
* @param Throwable $throwable
*
* @return void
* @throws Throwable
*/
public static function throw(EventLoop\Suspension $suspension, Throwable $throwable): void
{
$suspension->throw($throwable);
try {
$suspension->throw($throwable);
} catch (Throwable $exception) {
}
}
}
14 changes: 4 additions & 10 deletions src/Stream.php
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public function getTransaction(): Transaction|null
* @return bool
* @throws ConnectionTimeoutException
* @throws ConnectionCloseException
* @throws Throwable
*/
public function waitForReadable(int $timeout = 0): bool
{
Expand Down Expand Up @@ -344,13 +345,9 @@ public function waitForReadable(int $timeout = 0): bool
return $result;
} catch (ConnectionTimeoutException $e) {
throw $e;
} catch (ConnectionCloseException $e) {
} catch (ConnectionCloseException|Throwable $e) {
$this->close();
throw $e;
} catch (Throwable) {
//Generally speaking, no exception will be thrown here
$this->close();
return false;
}
}

Expand All @@ -367,6 +364,7 @@ public function waitForReadable(int $timeout = 0): bool
* @return bool
* @throws ConnectionCloseException
* @throws ConnectionTimeoutException
* @throws Throwable
*/
public function waitForWriteable(int $timeout = 0): bool
{
Expand Down Expand Up @@ -396,13 +394,9 @@ public function waitForWriteable(int $timeout = 0): bool
return $result;
} catch (ConnectionTimeoutException $e) {
throw $e;
} catch (ConnectionCloseException $e) {
} catch (ConnectionCloseException|Throwable $e) {
$this->close();
throw $e;
} catch (Throwable) {
//Generally speaking, no exception will be thrown here
$this->close();
return false;
}
}

Expand Down

0 comments on commit 545d8eb

Please sign in to comment.