Skip to content

[java] added annotations and applied format.sh exception classes pt2 #16025

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: trunk
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
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
8 changes: 6 additions & 2 deletions java/src/org/openqa/selenium/NoSuchSessionException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@

package org.openqa.selenium;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/** Thrown by any command being called after {@link WebDriver#quit() WebDriver.quit()}. */
@NullMarked
public class NoSuchSessionException extends WebDriverException {

public NoSuchSessionException() {}

public NoSuchSessionException(String reason) {
public NoSuchSessionException(@Nullable String reason) {
super(reason);
}

public NoSuchSessionException(String reason, Throwable cause) {
public NoSuchSessionException(@Nullable String reason, @Nullable Throwable cause) {
super(reason, cause);
}
}
10 changes: 7 additions & 3 deletions java/src/org/openqa/selenium/ScriptTimeoutException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@

package org.openqa.selenium;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/** Thrown when an async execute script command does not complete in enough time. */
@NullMarked
public class ScriptTimeoutException extends WebDriverException {

public ScriptTimeoutException() {}

public ScriptTimeoutException(String message) {
public ScriptTimeoutException(@Nullable String message) {
super(message);
}

public ScriptTimeoutException(Throwable cause) {
public ScriptTimeoutException(@Nullable Throwable cause) {
super(cause);
}

public ScriptTimeoutException(String message, Throwable cause) {
public ScriptTimeoutException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}
8 changes: 6 additions & 2 deletions java/src/org/openqa/selenium/SessionNotCreatedException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,20 @@

package org.openqa.selenium;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/** Indicates that a session could not be created. */
@NullMarked
public class SessionNotCreatedException extends WebDriverException {
public SessionNotCreatedException(String msg) {
public SessionNotCreatedException(@Nullable String msg) {
super(
"Could not start a new session. "
+ msg
+ (msg != null && msg.contains("Host info") ? "" : " \n" + getHostInformation()));
}

public SessionNotCreatedException(String msg, Throwable cause) {
public SessionNotCreatedException(@Nullable String msg, @Nullable Throwable cause) {
super(
"Could not start a new session. "
+ msg
Expand Down
10 changes: 7 additions & 3 deletions java/src/org/openqa/selenium/TimeoutException.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@

package org.openqa.selenium;

import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

/** Thrown when a command does not complete in enough time. */
@NullMarked
public class TimeoutException extends WebDriverException {

public TimeoutException() {}

public TimeoutException(String message) {
public TimeoutException(@Nullable String message) {
super(message);
}

public TimeoutException(Throwable cause) {
public TimeoutException(@Nullable Throwable cause) {
super(cause);
}

public TimeoutException(String message, Throwable cause) {
public TimeoutException(@Nullable String message, @Nullable Throwable cause) {
super(message, cause);
}
}
10 changes: 7 additions & 3 deletions java/src/org/openqa/selenium/UnhandledAlertException.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,23 +20,27 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import org.jspecify.annotations.NullMarked;
import org.jspecify.annotations.Nullable;

@NullMarked
public class UnhandledAlertException extends WebDriverException {

private final String alertText;
@Nullable private final String alertText;

public UnhandledAlertException(String message) {
public UnhandledAlertException(@Nullable String message) {
this(message, null);
}

public UnhandledAlertException(String message, String alertText) {
public UnhandledAlertException(@Nullable String message, @Nullable String alertText) {
super(message + ": " + alertText);
this.alertText = alertText;
}

/**
* @return the text of the unhandled alert.
*/
@Nullable
public String getAlertText() {
return alertText;
}
Expand Down