Skip to content

Commit 4299a68

Browse files
committed
refactor: 增加异常捕获
1 parent 6549b61 commit 4299a68

File tree

1 file changed

+3
-9
lines changed

1 file changed

+3
-9
lines changed

src/BootstrapBlazor.Server/Services/MockSocketServerService.cs

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,9 @@ private async Task MockSendAsync(TcpClient client, CancellationToken stoppingTok
4747

4848
await Task.Delay(10 * 1000, stoppingToken);
4949
}
50-
catch (OperationCanceledException)
51-
{
52-
// 任务被取消时退出
53-
break;
54-
}
55-
catch (SocketException)
56-
{
57-
break;
58-
}
50+
catch (OperationCanceledException) { break; }
51+
catch (IOException) { break; }
52+
catch (SocketException) { break; }
5953
catch (Exception ex)
6054
{
6155
logger.LogError(ex, "MockSocketServerService encountered an error while sending data.");

0 commit comments

Comments
 (0)