Skip to content

Commit

Permalink
catch when(...) changes
Browse files Browse the repository at this point in the history
  • Loading branch information
AoshiW committed Aug 5, 2023
1 parent 6649cad commit 96ec32e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
6 changes: 2 additions & 4 deletions src/TwitchLib.Communication/Clients/TcpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,7 @@ internal override async Task ListenTaskActionAsync()

await RaiseMessage(new OnMessageEventArgs(input));
}
catch (Exception ex) when (ex.GetType() == typeof(TaskCanceledException) ||
ex.GetType() == typeof(OperationCanceledException))
catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException)
{
// occurs if the Tasks are canceled by the CancellationTokenSource.Token
Logger?.LogExceptionAsInformation(GetType(), ex);
Expand Down Expand Up @@ -143,8 +142,7 @@ protected override async Task ConnectClientAsync()
_reader = new StreamReader(stream);
_writer = new StreamWriter(stream);
}
catch (Exception ex) when (ex.GetType() == typeof(TaskCanceledException) ||
ex.GetType() == typeof(OperationCanceledException))
catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException)
{
// occurs if the Tasks are canceled by the CancellationTokenSource.Token
Logger?.LogExceptionAsInformation(GetType(), ex);
Expand Down
3 changes: 1 addition & 2 deletions src/TwitchLib.Communication/Clients/WebsocketClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,7 @@ protected override async Task ConnectClientAsync()
Logger?.TraceAction(GetType(), "Client couldn't establish connection");
}
}
catch (Exception ex) when (ex.GetType() == typeof(TaskCanceledException) ||
ex.GetType() == typeof(OperationCanceledException))
catch (Exception ex) when (ex is TaskCanceledException or OperationCanceledException)
{
// occurs if the Tasks are canceled by the CancellationTokenSource.Token
Logger?.LogExceptionAsInformation(GetType(), ex);
Expand Down

0 comments on commit 96ec32e

Please sign in to comment.