Skip to content
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

[JENKINS-49331] Handle exceptions when rebuilding with invalid choice parameter #9027

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -7,6 +7,7 @@
import hudson.Extension;
import hudson.Util;
import hudson.util.FormValidation;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -160,8 +161,12 @@ public ParameterValue createValue(StaplerRequest req, JSONObject jo) {
}

private void checkValue(StringParameterValue value, String value2) {
if (!isValid(value)) {
throw new IllegalArgumentException("Illegal choice for parameter " + getName() + ": " + value2);
try {
if (!isValid(value)) {
throw new IOException("Illegal choice for parameter " + getName() + ": " + value2);
}
} catch (Exception e) {
throw new IllegalArgumentException("An unexpected error occured: ", e);
}
}

Expand Down