{"record":{"id":"165eea15ff4f100d","repo":"junit-team/junit5","slug":"e-getmessage","errorCode":null,"errorMessage":"${e.getMessage()}","messagePattern":"\\$\\{e\\.getMessage\\(\\)\\}","errorType":"console","errorClass":"ParameterException","httpStatus":null,"severity":"error","filePath":"junit-platform-console/src/main/java/org/junit/platform/console/command/BaseCommand.java","lineNumber":85,"sourceCode":"\t\t\t\t\tcommandLine.getErr().flush();\n\t\t\t\t\tcmd.usage(commandLine.getOut());\n\t\t\t\t\treturn ExitCode.ANY_ERROR;\n\t\t\t\t}) //\n\t\t\t\t.setCaseInsensitiveEnumValuesAllowed(true) //\n\t\t\t\t.setAtFileCommentChar(null);\n\t}\n\n\t@Override\n\tpublic final T call() {\n\t\tPrintWriter out = getOut();\n\t\tif (!disableBanner) {\n\t\t\tdisplayBanner(out);\n\t\t}\n\t\ttry {\n\t\t\treturn execute(out);\n\t\t}\n\t\tcatch (PreconditionViolationException e) {\n\t\t\tthrow new ParameterException(commandSpec.commandLine(), e.getMessage(), e.getCause());\n\t\t}\n\t}\n\n\tprivate PrintWriter getOut() {\n\t\treturn commandSpec.commandLine().getOut();\n\t}\n\n\tprivate void displayBanner(PrintWriter out) {\n\t\tout.println();\n\t\tCommandLine.Help.ColorScheme colorScheme = getColorScheme();\n\t\tif (colorScheme.ansi().enabled()) {\n\t\t\tout.print(\"💚 \");\n\t\t}\n\t\tout.println(colorScheme.string(\n\t\t\t\"@|italic Thanks for using JUnit!|@ Support its development at @|underline https://junit.org/sponsoring|@\"));\n\t\tout.println();\n\t\tout.flush();\n\t}","sourceCodeStart":67,"sourceCodeEnd":103,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-platform-console/src/main/java/org/junit/platform/console/command/BaseCommand.java#L67-L103","documentation":"This is a wrapper exception thrown by the picocli-based console launcher's BaseCommand.call() when a subcommand's execute() method throws a PreconditionViolationException. It converts the violation into a picocli ParameterException so the CLI can render usage help and a proper exit code rather than dumping a raw stack trace. The message content comes from the original precondition violation (e.getMessage()).","triggerScenarios":"Running the JUnit Platform Console Launcher (junit-platform-console[-standalone]) with invalid arguments that pass picocli parsing but fail a programmatic precondition inside a subcommand's execute() — e.g. mutually-exclusive options, a selector that cannot be resolved, or an invalid configuration parameter value. Any PreconditionViolationException raised downstream during discover/execute lands here.","commonSituations":"Invoking the standalone jar with a malformed --select, --scan-classpath with no matching classpath entries, passing --config KEY=VALUE with an invalid value, or combining options the subcommand later rejects. Common when scripting the console launcher in CI or from build tools.","solutions":["Read the full error message: it is the downstream precondition text (e.getMessage()), which identifies which argument/selector is at fault — fix that argument.","Re-run with --help on the specific subcommand (e.g. 'junit execute --help' or 'junit discover --help') to confirm accepted options and value formats.","If the underlying cause chain is unclear, temporarily remove --disable-banner is not relevant; instead enable picocli's stack trace by inspecting the printed usage, or run a tiny Launcher API call to reproduce the precondition outside the CLI.","Ensure the junit-platform-console and junit-platform-launcher versions are aligned (see error 112) so preconditions are not misreported."],"exampleFix":"// before\njava -jar junit-platform-console-standalone.jar execute --select 'bad spec' --config=''\n// after: provide a valid selector and config value\njava -jar junit-platform-console-standalone.jar execute --select-class com.example.MyTests --config 'junit.jupiter.testinstance.lifecycle.default=per_class'","handlingStrategy":"try-catch","validationCode":"// Validate selector strings before invoking the launcher programmatically.\n// For the CLI case, validate args at the script level:\nif (args.length == 0 || (!args[0].equals(\"discover\") && !args[0].equals(\"execute\"))) {\n  System.err.println(\"First arg must be 'discover' or 'execute' (or use --help/--version).\");\n  System.exit(2);\n}\n","typeGuard":null,"tryCatchPattern":"// When embedding the launcher, catch PreconditionViolationException before it is wrapped.\ntry {\n  LauncherFactory.create().execute(request);\n} catch (org.junit.platform.commons.PreconditionViolationException e) {\n  // handle invalid request construction\n  throw new IllegalArgumentException(\"Bad launcher request: \" + e.getMessage(), e);\n}","preventionTips":["When scripting the console launcher, validate the subcommand and selector options before invoking the jar.","Test new CLI invocations locally with --help before wiring them into CI.","Keep junit-platform-console, -launcher, and -engine versions aligned to avoid precondition differences."],"tags":["cli","picocli","argument-validation","console-launcher"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}