Make gradle.py print an actual exception instead of complaining that
raise needs an exception when executing gradle.

Make {d8/r8/compatdx}.py not print python error on failure, but
instead print only tool output and exit with correct exit code.

Bug:
Change-Id: I3f95ab293467fb0893f8cc13d0ec6e15ca019097
diff --git a/tools/compatdx.py b/tools/compatdx.py
index 75910b1..25a59db 100755
--- a/tools/compatdx.py
+++ b/tools/compatdx.py
@@ -32,7 +32,13 @@
       build = arg == "--build"
     else:
       args.append(arg)
-  run(args, build)
+  try:
+    run(args, build)
+  except subprocess.CalledProcessError as e:
+    # In case anything relevant was printed to stdout, normally this is already
+    # on stderr.
+    print(e.output)
+    return e.returncode
 
 if __name__ == '__main__':
   sys.exit(main())
diff --git a/tools/d8.py b/tools/d8.py
index 3eecf83..bf97845 100755
--- a/tools/d8.py
+++ b/tools/d8.py
@@ -36,7 +36,13 @@
       build = arg == "--build"
     else:
       args.append(arg)
-  run(args, build)
+  try:
+    run(args, build)
+  except subprocess.CalledProcessError as e:
+    # In case anything relevant was printed to stdout, normally this is already
+    # on stderr.
+    print(e.output)
+    return e.returncode
 
 if __name__ == '__main__':
   sys.exit(main())
diff --git a/tools/gradle.py b/tools/gradle.py
index df80cc9..2303bce 100755
--- a/tools/gradle.py
+++ b/tools/gradle.py
@@ -66,7 +66,7 @@
   with utils.ChangedWorkingDirectory(utils.REPO_ROOT):
     return_value = subprocess.call(cmd)
     if throw_on_failure and return_value != 0:
-      raise
+      raise Exception('Failed to execute gradle')
     return return_value
 
 def RunGradleExcludeDeps(args, throw_on_failure=True):
diff --git a/tools/r8.py b/tools/r8.py
index fe38dd0..3ae4da7 100755
--- a/tools/r8.py
+++ b/tools/r8.py
@@ -36,7 +36,13 @@
       build = arg == "--build"
     else:
       args.append(arg)
-  run(args, build)
+  try:
+    run(args, build)
+  except subprocess.CalledProcessError as e:
+    # In case anything relevant was printed to stdout, normally this is already
+    # on stderr.
+    print(e.output)
+    return e.returncode
 
 if __name__ == '__main__':
   sys.exit(main())