Skip to content

Commit b30ec03

Browse files
committed
[dotnet] link exceptions to documentation
1 parent cb9cdc1 commit b30ec03

File tree

4 files changed

+65
-9
lines changed

4 files changed

+65
-9
lines changed

dotnet/src/webdriver/InvalidSelectorException.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@ namespace OpenQA.Selenium
2727
[Serializable]
2828
public class InvalidSelectorException : WebDriverException
2929
{
30+
/// <summary>
31+
/// Link to the documentation for this error
32+
/// </summary>
33+
private static string supportUrl = baseSupportUrl + "#invalid-selector-exception";
34+
3035
/// <summary>
3136
/// Initializes a new instance of the <see cref="InvalidSelectorException"/> class.
3237
/// </summary>
3338
public InvalidSelectorException()
34-
: base()
39+
: base(GetMessage(""))
3540
{
3641
}
3742

@@ -41,7 +46,7 @@ public InvalidSelectorException()
4146
/// </summary>
4247
/// <param name="message">The message that describes the error.</param>
4348
public InvalidSelectorException(string message)
44-
: base(message)
49+
: base(GetMessage(message))
4550
{
4651
}
4752

@@ -54,7 +59,7 @@ public InvalidSelectorException(string message)
5459
/// <param name="innerException">The exception that is the cause of the current exception,
5560
/// or <see langword="null"/> if no inner exception is specified.</param>
5661
public InvalidSelectorException(string message, Exception innerException)
57-
: base(message, innerException)
62+
: base(GetMessage(message), innerException)
5863
{
5964
}
6065

@@ -69,5 +74,15 @@ protected InvalidSelectorException(SerializationInfo info, StreamingContext cont
6974
: base(info, context)
7075
{
7176
}
77+
78+
/// <summary>
79+
/// Add information about obtaining additional support from documentation to this exception.
80+
/// </summary>
81+
/// <param name="message">The original message for exception</param>
82+
/// <returns>The final message for exception</returns>
83+
protected static string GetMessage(string message)
84+
{
85+
return message + "; " + supportMsg + supportUrl;
86+
}
7287
}
7388
}

dotnet/src/webdriver/NoSuchElementException.cs

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,17 @@ namespace OpenQA.Selenium
2727
[Serializable]
2828
public class NoSuchElementException : NotFoundException
2929
{
30+
31+
/// <summary>
32+
/// Link to the documentation for this error
33+
/// </summary>
34+
private static string supportUrl = baseSupportUrl + "#no-such-element-exception";
35+
3036
/// <summary>
3137
/// Initializes a new instance of the <see cref="NoSuchElementException"/> class.
3238
/// </summary>
3339
public NoSuchElementException()
34-
: base()
40+
: base(GetMessage(""))
3541
{
3642
}
3743

@@ -41,7 +47,7 @@ public NoSuchElementException()
4147
/// </summary>
4248
/// <param name="message">The message that describes the error.</param>
4349
public NoSuchElementException(string message)
44-
: base(message)
50+
: base(GetMessage(message))
4551
{
4652
}
4753

@@ -54,7 +60,7 @@ public NoSuchElementException(string message)
5460
/// <param name="innerException">The exception that is the cause of the current exception,
5561
/// or <see langword="null"/> if no inner exception is specified.</param>
5662
public NoSuchElementException(string message, Exception innerException)
57-
: base(message, innerException)
63+
: base(GetMessage(message), innerException)
5864
{
5965
}
6066

@@ -69,5 +75,15 @@ protected NoSuchElementException(SerializationInfo info, StreamingContext contex
6975
: base(info, context)
7076
{
7177
}
78+
79+
/// <summary>
80+
/// Add information about obtaining additional support from documentation to this exception.
81+
/// </summary>
82+
/// <param name="message">The original message for exception</param>
83+
/// <returns>The final message for exception</returns>
84+
protected static string GetMessage(string message)
85+
{
86+
return message + "; " + supportMsg + supportUrl;
87+
}
7288
}
7389
}

dotnet/src/webdriver/StaleElementReferenceException.cs

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,16 @@ namespace OpenQA.Selenium
2727
[Serializable]
2828
public class StaleElementReferenceException : WebDriverException
2929
{
30+
/// <summary>
31+
/// Link to the documentation for this error
32+
/// </summary>
33+
private static string supportUrl = baseSupportUrl + "#stale-element-reference-exception";
34+
3035
/// <summary>
3136
/// Initializes a new instance of the <see cref="StaleElementReferenceException"/> class.
3237
/// </summary>
3338
public StaleElementReferenceException()
34-
: base()
39+
: base(GetMessage(""))
3540
{
3641
}
3742

@@ -41,7 +46,7 @@ public StaleElementReferenceException()
4146
/// </summary>
4247
/// <param name="message">The message that describes the error.</param>
4348
public StaleElementReferenceException(string message)
44-
: base(message)
49+
: base(GetMessage(message))
4550
{
4651
}
4752

@@ -54,7 +59,7 @@ public StaleElementReferenceException(string message)
5459
/// <param name="innerException">The exception that is the cause of the current exception,
5560
/// or <see langword="null"/> if no inner exception is specified.</param>
5661
public StaleElementReferenceException(string message, Exception innerException)
57-
: base(message, innerException)
62+
: base(GetMessage(message), innerException)
5863
{
5964
}
6065

@@ -69,5 +74,15 @@ protected StaleElementReferenceException(SerializationInfo info, StreamingContex
6974
: base(info, context)
7075
{
7176
}
77+
78+
/// <summary>
79+
/// Add information about obtaining additional support from documentation to this exception.
80+
/// </summary>
81+
/// <param name="message">The original message for exception</param>
82+
/// <returns>The final message for exception</returns>
83+
protected static string GetMessage(string message)
84+
{
85+
return message + "; " + supportMsg + supportUrl;
86+
}
7287
}
7388
}

dotnet/src/webdriver/WebDriverException.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,16 @@ namespace OpenQA.Selenium
2727
[Serializable]
2828
public class WebDriverException : Exception
2929
{
30+
/// <summary>
31+
/// Intro comment for pointing to documentation
32+
/// </summary>
33+
protected static string supportMsg = "For documentation on this error, please visit: ";
34+
35+
/// <summary>
36+
/// Location of errors in documentation
37+
/// </summary>
38+
protected static string baseSupportUrl = "https://www.selenium.dev/documentation/webdriver/troubleshooting/errors";
39+
3040
/// <summary>
3141
/// Initializes a new instance of the <see cref="WebDriverException"/> class.
3242
/// </summary>

0 commit comments

Comments
 (0)