Skip to content

Commit 736154e

Browse files
committed
[dotnet] Remove out-of-spec UnhandledError error status
1 parent cc5ca35 commit 736154e

File tree

6 files changed

+118
-9
lines changed

6 files changed

+118
-9
lines changed

dotnet/src/webdriver/Remote/HttpCommandExecutor.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ private Response CreateResponse(HttpResponseInfo responseInfo)
326326
}
327327
else
328328
{
329-
response.Status = WebDriverResult.UnhandledError;
329+
response.Status = WebDriverResult.UnknownError;
330330
response.Value = body;
331331
}
332332
}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// <copyright file="UnknownErrorException.cs" company="Selenium Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
// </copyright>
19+
20+
using System;
21+
22+
#nullable enable
23+
24+
namespace OpenQA.Selenium
25+
{
26+
/// <summary>
27+
/// An unknown error occurred in the remote end while processing the command.
28+
/// </summary>
29+
[Serializable]
30+
public class UnknownErrorException : WebDriverException
31+
{
32+
/// <summary>
33+
/// Initializes a new instance of the <see cref="UnknownErrorException"/> class with the specified message.
34+
/// </summary>
35+
/// <param name="message">The message of the exception.</param>
36+
public UnknownErrorException(string? message)
37+
: base(message)
38+
{
39+
}
40+
41+
/// <summary>
42+
/// Initializes a new instance of the <see cref="UnknownErrorException"/> class with the specified message and inner exception.
43+
/// </summary>
44+
/// <param name="message">The message of the exception.</param>
45+
/// <param name="innerException">The inner exception for this exception.</param>
46+
public UnknownErrorException(string? message, Exception? innerException)
47+
: base(message, innerException)
48+
{
49+
}
50+
}
51+
}
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
// <copyright file="UnsupportedOperationException.cs" company="Selenium Committers">
2+
// Licensed to the Software Freedom Conservancy (SFC) under one
3+
// or more contributor license agreements. See the NOTICE file
4+
// distributed with this work for additional information
5+
// regarding copyright ownership. The SFC licenses this file
6+
// to you under the Apache License, Version 2.0 (the
7+
// "License"); you may not use this file except in compliance
8+
// with the License. You may obtain a copy of the License at
9+
//
10+
// http://www.apache.org/licenses/LICENSE-2.0
11+
//
12+
// Unless required by applicable law or agreed to in writing,
13+
// software distributed under the License is distributed on an
14+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15+
// KIND, either express or implied. See the License for the
16+
// specific language governing permissions and limitations
17+
// under the License.
18+
// </copyright>
19+
20+
using System;
21+
22+
#nullable enable
23+
24+
namespace OpenQA.Selenium
25+
{
26+
/// <summary>
27+
/// Indicates that a command that should have executed properly cannot be supported for some reason.
28+
/// </summary>
29+
public class UnsupportedOperationException : WebDriverException
30+
{
31+
/// <summary>
32+
/// Initializes a new instance of the <see cref="UnsupportedOperationException"/> class with the specified message.
33+
/// </summary>
34+
/// <param name="message">The message of the exception.</param>
35+
public UnsupportedOperationException(string? message)
36+
: base(message)
37+
{
38+
}
39+
40+
/// <summary>
41+
/// Initializes a new instance of the <see cref="UnsupportedOperationException"/> class with the specified message and inner exception.
42+
/// </summary>
43+
/// <param name="message">The message of the exception.</param>
44+
/// <param name="innerException">The inner exception for this exception.</param>
45+
public UnsupportedOperationException(string? message, Exception? innerException)
46+
: base(message, innerException)
47+
{
48+
}
49+
}
50+
}

dotnet/src/webdriver/WebDriver.cs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,7 @@ protected virtual async Task<Response> ExecuteAsync(string driverCommandToExecut
622622
{
623623
commandResponse = new Response
624624
{
625-
Status = WebDriverResult.UnhandledError,
625+
Status = WebDriverResult.UnknownError,
626626
Value = e
627627
};
628628
}
@@ -782,9 +782,6 @@ private static void UnpackAndThrowOnError(Response errorResponse, string command
782782
case WebDriverResult.ElementNotSelectable:
783783
throw new InvalidElementStateException(errorMessage);
784784

785-
case WebDriverResult.UnhandledError:
786-
throw new WebDriverException(errorMessage);
787-
788785
case WebDriverResult.NoSuchDocument:
789786
throw new NoSuchElementException(errorMessage);
790787

@@ -854,6 +851,12 @@ private static void UnpackAndThrowOnError(Response errorResponse, string command
854851
case WebDriverResult.InsecureCertificate:
855852
throw new InsecureCertificateException(errorMessage);
856853

854+
case WebDriverResult.UnknownError:
855+
throw new UnknownErrorException(errorMessage);
856+
857+
case WebDriverResult.UnsupportedOperation:
858+
throw new UnsupportedOperationException(errorMessage);
859+
857860
default:
858861
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "{0} ({1})", errorMessage, errorResponse.Status));
859862
}

dotnet/src/webdriver/WebDriverError.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,9 +223,9 @@ static WebDriverError()
223223
resultMap[UnableToCaptureScreen] = WebDriverResult.UnableToCaptureScreen;
224224
resultMap[UnexpectedAlertOpen] = WebDriverResult.UnexpectedAlertOpen;
225225
resultMap[UnknownCommand] = WebDriverResult.UnknownCommand;
226-
resultMap[UnknownError] = WebDriverResult.UnhandledError;
226+
resultMap[UnknownError] = WebDriverResult.UnknownError;
227227
resultMap[UnknownMethod] = WebDriverResult.UnknownCommand;
228-
resultMap[UnsupportedOperation] = WebDriverResult.UnhandledError;
228+
resultMap[UnsupportedOperation] = WebDriverResult.UnsupportedOperation;
229229
}
230230

231231
/// <summary>

dotnet/src/webdriver/WebDriverResult.cs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,9 +90,9 @@ public enum WebDriverResult
9090
InvalidElementState = 12,
9191

9292
/// <summary>
93-
/// An unhandled error occurred.
93+
/// An unknown error occurred in the remote end while processing the command.
9494
/// </summary>
95-
UnhandledError = 13,
95+
UnknownError = 13,
9696

9797
/// <summary>
9898
/// An error occurred, but it was expected.
@@ -233,5 +233,10 @@ public enum WebDriverResult
233233
/// The referenced shadow root is no longer attached to the DOM.
234234
/// </summary>
235235
DetachedShadowRoot = 66,
236+
237+
/// <summary>
238+
/// Indicates that a command that should have executed properly cannot be supported for some reason.
239+
/// </summary>
240+
UnsupportedOperation = 67,
236241
}
237242
}

0 commit comments

Comments
 (0)