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-52744 Showing meaningful error when an environment variable i… #309

Merged
merged 6 commits into from Jan 10, 2019
Expand Up @@ -455,7 +455,7 @@ class ModelInterpreter implements Serializable {
"${k}=${v.call()}"
}catch (NullPointerException e){

throw new IllegalArgumentException(format("Invalid var declared in environment: %s", k))
throw new IllegalArgumentException(format("Invalid variable (%s) declared in environment; There are some problems with its value", k))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So in practice, this is only going to show up if there's a reference to a non-existent variable in the value, right? Hence the NullPointerException - so in that case, we could probably be more specific and say something like One or more variables in its value do not exist?

Also, this should go in Messages.properties so that it can be localized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't want to narrow that much the error, what if another issue comes up as NPE?

}
}.findAll { it != null}
return {
Expand Down
Expand Up @@ -333,7 +333,7 @@ public void notExpressionInEnvironment() throws Exception {
@Test
public void improveMessageErrorWhenEnvVarNotExists() throws Exception {
expect(Result.FAILURE, "improveMessageErrorWhenEnvVarNotExists")
.logContains("IllegalArgumentException: Invalid var declared in environment: FOO")
.logContains("IllegalArgumentException: Invalid variable (FOO) declared in environment; There are some problems with its value")
.go();
}
}