How to disable gradle output even task failed?

I’m developing a CLI Appication, when I run

./gradlew run --args="<some invalid inputs>"

It outputs both my custom error message and a ‘build failed’ message.

example output:

<app output>

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':run'.
...
...
... and more

I want to remove this error message. I tried adding -q, but -q does not disable error logging (quiet, not quite). See Logging .

Additionally, the documentation says that useLogger can be used to customize the logging, but it was removed in Gradle 8.10.

2> /dev/null will not work because my custom error message is also output to stderr.

So, any way to disable all output from gradle?

What bothers you with the build failed?
You only do this to test your CLI, right?