private function tryAppOnClose(int $clientId, $code, $reason) : \Generator
{
try {
$onCloseResult = $this->application->onClose($clientId, $code, $reason);
if ($onCloseResult instanceof \Generator) {
$onCloseResult = (yield from $onCloseResult);
}
} catch (\Throwable $e) {
yield from $this->onAppError($clientId, $e);
}
}