Skip to content

Commit 73573b5

Browse files
authored
Add missing TrySetExceptions (#1157)
1 parent 3953bb9 commit 73573b5

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

lib/PuppeteerSharp/CDPSession.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public async Task<JObject> SendAsync(string method, object args = null, bool wai
149149
{
150150
if (waitForCallback && _callbacks.TryRemove(id, out _))
151151
{
152-
callback.TaskWrapper.SetException(new MessageException(ex.Message, ex));
152+
callback.TaskWrapper.TrySetException(new MessageException(ex.Message, ex));
153153
}
154154
}
155155

lib/PuppeteerSharp/ChromiumProcess.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,8 @@ void OnProcessDataReceivedWhileStarting(object sender, DataReceivedEventArgs e)
522522
}
523523
}
524524
void OnProcessExitedWhileStarting(object sender, EventArgs e)
525-
{
526-
p._startCompletionSource.SetException(new ChromiumProcessException($"Failed to launch Chromium! {output}"));
527-
}
528-
void OnProcessExited(object sender, EventArgs e)
529-
{
530-
Exited.EnterFrom(p, p._currentState);
531-
}
525+
=> p._startCompletionSource.TrySetException(new ChromiumProcessException($"Failed to launch Chromium! {output}"));
526+
void OnProcessExited(object sender, EventArgs e) => Exited.EnterFrom(p, p._currentState);
532527

533528
p.Process.ErrorDataReceived += OnProcessDataReceivedWhileStarting;
534529
p.Process.Exited += OnProcessExitedWhileStarting;

lib/PuppeteerSharp/WaitTask.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ await _world.EvaluateFunctionAsync<bool>("s => !s", success)
205205

206206
if (exception != null)
207207
{
208-
_taskCompletion.SetException(exception);
208+
_taskCompletion.TrySetException(exception);
209209
}
210210
else
211211
{

0 commit comments

Comments
 (0)