Skip to content

Commit 1fe04bf

Browse files
committed
Do not catch OperationCanceledException
1 parent 24ff130 commit 1fe04bf

File tree

3 files changed

+5
-9
lines changed

3 files changed

+5
-9
lines changed

src/BuiltInTools/AspireService/AspireServerService.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ private async ValueTask SendNotificationAsync<TNotification>(TNotification notif
170170
var jsonSerialized = JsonSerializer.SerializeToUtf8Bytes(notification, JsonSerializerOptions);
171171
await SendMessageAsync(dcpId, jsonSerialized, cancelationToken);
172172
}
173-
catch (Exception e) when (LogAndPropagate(e))
173+
catch (Exception e) when (e is not OperationCanceledException && LogAndPropagate(e))
174174
{
175175
}
176176

@@ -340,7 +340,7 @@ private async Task HandleStartSessionRequestAsync(HttpContext context)
340340
context.Response.StatusCode = (int)HttpStatusCode.Created;
341341
context.Response.Headers.Location = $"{context.Request.Scheme}://{context.Request.Host}{context.Request.Path}/{sessionId}";
342342
}
343-
catch (Exception e)
343+
catch (Exception e) when (e is not OperationCanceledException)
344344
{
345345
Log($"Failed to start project{(projectPath == null ? "" : $" '{projectPath}'")}: {e}");
346346

@@ -419,7 +419,7 @@ private async ValueTask HandleStopSessionRequestAsync(HttpContext context, strin
419419
var sessionExists = await _aspireServerEvents.StopSessionAsync(context.GetDcpId(), sessionId, _shutdownCancellationTokenSource.Token);
420420
context.Response.StatusCode = (int)(sessionExists ? HttpStatusCode.OK : HttpStatusCode.NoContent);
421421
}
422-
catch (Exception e)
422+
catch (Exception e) when (e is not OperationCanceledException)
423423
{
424424
Log($"[#{sessionId}] Failed to stop: {e}");
425425

src/BuiltInTools/dotnet-watch/Aspire/AspireServiceFactory.cs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -157,11 +157,7 @@ async Task StartChannelReader(CancellationToken cancellationToken)
157157
await _service.NotifyLogMessageAsync(dcpId, sessionId, isStdErr: line.IsError, data: line.Content, cancellationToken);
158158
}
159159
}
160-
catch (OperationCanceledException)
161-
{
162-
// nop
163-
}
164-
catch (Exception e)
160+
catch (Exception e) when (e is not OperationCanceledException)
165161
{
166162
Reporter.Error($"Unexpected error reading output of session '{sessionId}': {e}");
167163
}

src/BuiltInTools/dotnet-watch/Build/ProjectGraphUtilities.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ internal static class ProjectGraphUtilities
3939

4040
return new ProjectGraph([entryPoint], collection, projectInstanceFactory: null, cancellationToken);
4141
}
42-
catch (Exception e)
42+
catch (Exception e) when (e is not OperationCanceledException)
4343
{
4444
reporter.Verbose("Failed to load project graph.");
4545

0 commit comments

Comments
 (0)