Skip to content

Commit 47ebeb5

Browse files
committed
EnsureValueIsNotNull can return itself
1 parent 2877cce commit 47ebeb5

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

dotnet/src/webdriver/Response.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,9 +221,14 @@ public string ToJson()
221221
/// </summary>
222222
/// <exception cref="WebDriverException">If <see cref="Value"/> is <see langword="null"/>.</exception>
223223
[MemberNotNull(nameof(Value))]
224-
internal object EnsureValueIsNotNull(string? errorMessage = null)
224+
internal Response EnsureValueIsNotNull(string commandName)
225225
{
226-
return Value ?? throw new WebDriverException(errorMessage ?? "Expected not-null response");
226+
if (Value is null)
227+
{
228+
throw new WebDriverException($"{commandName} command returned a successful result, but contained no data");
229+
}
230+
231+
return this;
227232
}
228233

229234
/// <summary>

0 commit comments

Comments
 (0)