title: Gradle doesn't catch exception
body: <p>I am running a very simple Gradle  task.<br>
  which run Yarn command - yarn_test which run Selenium tests.<br>
  I am using com.moowork.gradle:gradle-node-plugin:1.2.0 plugin in order to run Yarn commands
  my task look like -</p>
  
  <pre><code>task run_tests(type: YarnTask) {
  try {
      args = ['test']
  }catch (all){
      println('Tests failed!')
  }}
  </code></pre>
  
  <p>and in my packge.json i have:<br>
  "test": "mocha --timeout 25000 ./automation/test --reporter xunit-file"</p>
  
  <p>even when I changed it to run as exec <br>
          <code>executable "sh"</code><br>
          <code>args "-c", "yarn test"</code></p>
  
  <p>I got the same error, so it is not something with the plugin but, with Gradle try-catch</p>
  
  <p>when even one test fail no meter why I want to catch the exception.
  but for some reason it doesn't get caught.</p>
  
  <p>when I run with --stacktrace this is what I get-</p>
  
  <blockquote>
    <p>error Command failed with exit code 2.
    info Visit <a href="https://yarnpkg.com/en/docs/cli/run" rel="nofollow noreferrer">https://yarnpkg.com/en/docs/cli/run</a> for documentation about this command.</p>
    
    <p>Task :run_tests FAILED
    FAILURE: Build failed with an exception.
    * What went wrong:
    Execution failed for task ':run_tests'.
    Process 'command '/DATA/build/workspace/build_build/.gradle/yarn/yarn-v1.3.2/bin/yarn'' finished with non-zero exit value 1
    * Try:
    Run with --info or --debug option to get more log output. Run with --scan to get full insights.
    * Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':run_tests'.</p>
  </blockquote>
  
  <p>What am I missing?<br>
  All I want is to print some error, and finish the build.. but not with exception?!<br>
  Gradle 4.7, run on Ubuntu with Gradle wrapper.
  Thanks</p>
  
  <p><b> EDIT</b></p>
  
  <p>even when i run just</p>
  
  <pre><code>sh: exit 1
  </code></pre>
  
  <p>I got same result so, it has to be something with gradle try-catch and not with yarn ormocha etc</p>