Skip to content

Commit bdf2895

Browse files
committed
rename to onThrowable
1 parent 676835c commit bdf2895

File tree

5 files changed

+14
-14
lines changed

5 files changed

+14
-14
lines changed

core/src/main/java/hudson/cli/CLICommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ public int main(List<String> args, Locale locale, InputStream stdin, PrintStream
266266
return res;
267267
} catch (Throwable e) {
268268
int exitCode = handleException(e, context, p);
269-
Listeners.notify(CLIListener.class, true, listener -> listener.onException(context, e));
269+
Listeners.notify(CLIListener.class, true, listener -> listener.onThrowable(context, e));
270270
return exitCode;
271271
} finally {
272272
if (sc != null)

core/src/main/java/hudson/cli/declarative/CLIRegisterer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -233,7 +233,7 @@ public int main(List<String> args, Locale locale, InputStream stdin, PrintStream
233233
}
234234
} catch (Throwable e) {
235235
int exitCode = handleException(e, context, parser);
236-
Listeners.notify(CLIListener.class, true, listener -> listener.onException(context, e));
236+
Listeners.notify(CLIListener.class, true, listener -> listener.onThrowable(context, e));
237237
return exitCode;
238238
}
239239
}

core/src/main/java/jenkins/cli/listeners/CLIListener.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,23 +38,23 @@ public interface CLIListener extends ExtensionPoint {
3838
/**
3939
* Invoked before command execution.
4040
*
41-
* @param context Information about the command being executed
41+
* @param context Information about the command being executed.
4242
* */
4343
default void onExecution(@NonNull CLIContext context) {}
4444

4545
/**
4646
* Invoked after command execution.
4747
*
48-
* @param context Information about the command being executed
48+
* @param context Information about the command being executed.
4949
* @param exitCode Exit code returned by the implementation of {@link CLICommand#run()}.
5050
* */
5151
default void onCompleted(@NonNull CLIContext context, int exitCode) {}
5252

5353
/**
54-
* Invoked on command exception.
54+
* Invoked when an exception or error occurs during command execution.
5555
*
56-
* @param context Information about the command being executed
56+
* @param context Information about the command being executed.
5757
* @param t Any error during the execution of the command.
5858
* */
59-
default void onException(@NonNull CLIContext context, @NonNull Throwable t) {}
59+
default void onThrowable(@NonNull CLIContext context, @NonNull Throwable t) {}
6060
}

core/src/main/java/jenkins/cli/listeners/DefaultCLIListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public void onCompleted(CLIContext context, int exitCode) {
5959
}
6060

6161
@Override
62-
public void onException(CLIContext context, Throwable t) {
62+
public void onThrowable(CLIContext context, Throwable t) {
6363
if (t instanceof BadCredentialsException) {
6464
// to the caller (stderr), we can't reveal whether the user didn't exist or the password didn't match.
6565
// do that to the server log instead

test/src/test/java/jenkins/cli/DefaultCLIListenerTest.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ public void setUp() throws IOException {
6767
}
6868

6969
@Test
70-
public void commandExecutionSuccessIsLogged() throws Exception {
70+
public void commandOnCompletedIsLogged() throws Exception {
7171
CLICommandInvoker command = new CLICommandInvoker(j, new ListJobsCommand());
7272
command.asUser(USER).invoke();
7373

@@ -83,7 +83,7 @@ public void commandExecutionSuccessIsLogged() throws Exception {
8383
}
8484

8585
@Test
86-
public void commandExecutionErrorIsLogged() throws Exception {
86+
public void commandOnThrowableIsLogged() throws Exception {
8787
CLICommandInvoker command = new CLICommandInvoker(j, new ListJobsCommand());
8888
command.asUser(USER).invokeWithArgs("view-not-found");
8989

@@ -101,7 +101,7 @@ public void commandExecutionErrorIsLogged() throws Exception {
101101
}
102102

103103
@Test
104-
public void commandExecutionUnexpectedErrorIsLogged() throws Exception {
104+
public void commandOnThrowableUnexpectedIsLogged() throws Exception {
105105
CLICommandInvoker command = new CLICommandInvoker(j, new ThrowsTestCommand());
106106
command.asUser(USER).invoke();
107107

@@ -118,7 +118,7 @@ public void commandExecutionUnexpectedErrorIsLogged() throws Exception {
118118
}
119119

120120
@Test
121-
public void methodExecutionSuccessIsLogged() throws Exception {
121+
public void methodOnCompletedIsLogged() throws Exception {
122122
CLICommandInvoker command = new CLICommandInvoker(j, "disable-job");
123123
command.asUser(USER).invokeWithArgs("p");
124124

@@ -134,7 +134,7 @@ public void methodExecutionSuccessIsLogged() throws Exception {
134134
}
135135

136136
@Test
137-
public void methodExecutionErrorIsLogged() throws Exception {
137+
public void methodOnThrowableIsLogged() throws Exception {
138138
CLICommandInvoker command = new CLICommandInvoker(j, "disable-job");
139139
command.asUser(USER).invokeWithArgs("job-not-found");
140140

@@ -153,7 +153,7 @@ public void methodExecutionErrorIsLogged() throws Exception {
153153
}
154154

155155
@Test
156-
public void methodExecutionUnexpectedErrorIsLogged() throws Exception {
156+
public void methodOnThrowableUnexpectedIsLogged() throws Exception {
157157
CLICommandInvoker command = new CLICommandInvoker(j, "restart");
158158
command.asUser(USER).invoke();
159159

0 commit comments

Comments
 (0)