Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dotnet/src/webdriver/Remote/HttpCommandExecutor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ private Response CreateResponse(HttpResponseInfo responseInfo)
}
else
{
response.Status = WebDriverResult.UnhandledError;
response.Status = WebDriverResult.UnknownError;
response.Value = body;
}
}
Expand Down
51 changes: 51 additions & 0 deletions dotnet/src/webdriver/UnknownErrorException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
// <copyright file="UnknownErrorException.cs" company="Selenium Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// </copyright>

using System;

#nullable enable

namespace OpenQA.Selenium
{
/// <summary>
/// An unknown error occurred in the remote end while processing the command.
/// </summary>
[Serializable]
public class UnknownErrorException : WebDriverException
{
/// <summary>
/// Initializes a new instance of the <see cref="UnknownErrorException"/> class with the specified message.
/// </summary>
/// <param name="message">The message of the exception.</param>
public UnknownErrorException(string? message)
: base(message)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="UnknownErrorException"/> class with the specified message and inner exception.
/// </summary>
/// <param name="message">The message of the exception.</param>
/// <param name="innerException">The inner exception for this exception.</param>
public UnknownErrorException(string? message, Exception? innerException)
: base(message, innerException)
{
}
}
}
50 changes: 50 additions & 0 deletions dotnet/src/webdriver/UnsupportedOperationException.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
// <copyright file="UnsupportedOperationException.cs" company="Selenium Committers">
// Licensed to the Software Freedom Conservancy (SFC) under one
// or more contributor license agreements. See the NOTICE file
// distributed with this work for additional information
// regarding copyright ownership. The SFC licenses this file
// to you under the Apache License, Version 2.0 (the
// "License"); you may not use this file except in compliance
// with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
// </copyright>

using System;

#nullable enable

namespace OpenQA.Selenium
{
/// <summary>
/// Indicates that a command that should have executed properly cannot be supported for some reason.
/// </summary>
public class UnsupportedOperationException : WebDriverException
{
/// <summary>
/// Initializes a new instance of the <see cref="UnsupportedOperationException"/> class with the specified message.
/// </summary>
/// <param name="message">The message of the exception.</param>
public UnsupportedOperationException(string? message)
: base(message)
{
}

/// <summary>
/// Initializes a new instance of the <see cref="UnsupportedOperationException"/> class with the specified message and inner exception.
/// </summary>
/// <param name="message">The message of the exception.</param>
/// <param name="innerException">The inner exception for this exception.</param>
public UnsupportedOperationException(string? message, Exception? innerException)
: base(message, innerException)
{
}
}
}
11 changes: 7 additions & 4 deletions dotnet/src/webdriver/WebDriver.cs
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ protected virtual async Task<Response> ExecuteAsync(string driverCommandToExecut
{
commandResponse = new Response
{
Status = WebDriverResult.UnhandledError,
Status = WebDriverResult.UnknownError,
Value = e
};
}
Expand Down Expand Up @@ -782,9 +782,6 @@ private static void UnpackAndThrowOnError(Response errorResponse, string command
case WebDriverResult.ElementNotSelectable:
throw new InvalidElementStateException(errorMessage);

case WebDriverResult.UnhandledError:
throw new WebDriverException(errorMessage);

case WebDriverResult.NoSuchDocument:
throw new NoSuchElementException(errorMessage);

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

case WebDriverResult.UnknownError:
throw new UnknownErrorException(errorMessage);

case WebDriverResult.UnsupportedOperation:
throw new UnsupportedOperationException(errorMessage);

default:
throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "{0} ({1})", errorMessage, errorResponse.Status));
}
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/webdriver/WebDriverError.cs
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,9 @@ static WebDriverError()
resultMap[UnableToCaptureScreen] = WebDriverResult.UnableToCaptureScreen;
resultMap[UnexpectedAlertOpen] = WebDriverResult.UnexpectedAlertOpen;
resultMap[UnknownCommand] = WebDriverResult.UnknownCommand;
resultMap[UnknownError] = WebDriverResult.UnhandledError;
resultMap[UnknownError] = WebDriverResult.UnknownError;
resultMap[UnknownMethod] = WebDriverResult.UnknownCommand;
resultMap[UnsupportedOperation] = WebDriverResult.UnhandledError;
resultMap[UnsupportedOperation] = WebDriverResult.UnsupportedOperation;
}

/// <summary>
Expand Down
9 changes: 7 additions & 2 deletions dotnet/src/webdriver/WebDriverResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ public enum WebDriverResult
InvalidElementState = 12,

/// <summary>
/// An unhandled error occurred.
/// An unknown error occurred in the remote end while processing the command.
/// </summary>
UnhandledError = 13,
UnknownError = 13,

/// <summary>
/// An error occurred, but it was expected.
Expand Down Expand Up @@ -233,5 +233,10 @@ public enum WebDriverResult
/// The referenced shadow root is no longer attached to the DOM.
/// </summary>
DetachedShadowRoot = 66,

/// <summary>
/// Indicates that a command that should have executed properly cannot be supported for some reason.
/// </summary>
UnsupportedOperation = 67,
}
}