Separate error handling for curl error and mkdirs error

If creating the cache directory fails, it is reported as a failure
to run curl.

Separate the error handling and print an appropriate error message.

At the same time, remove redundant calls to `str()` when printing
error messages.

Change-Id: Id6f2c76b16b3101f800cc194a5cb0c2875c4414a
diff --git a/tools/download_jar.py b/tools/download_jar.py
index 2647e6f..27d619e 100755
--- a/tools/download_jar.py
+++ b/tools/download_jar.py
@@ -125,8 +125,12 @@
     safe_mkdirs(path.dirname(cache_ent))
     print('Download %s' % src_url, file=stderr)
     check_call(['curl', '--proxy-anyauth', '-sfo', cache_ent, src_url])
-  except (OSError, CalledProcessError) as err:
-    print('error using curl: %s' % str(err), file=stderr)
+  except OSError as err:
+    print('error creating directory %s: %s' %
+          (path.dirname(cache_ent), err), file=stderr)
+    exit(1)
+  except CalledProcessError as err:
+    print('error using curl: %s' % err, file=stderr)
     exit(1)
 
 if args.v:
@@ -153,7 +157,7 @@
     finally:
       zf.close()
   except (BadZipfile, LargeZipFile) as err:
-    print("error opening %s: %s"  % (cache_ent, str(err)), file=stderr)
+    print("error opening %s: %s"  % (cache_ent, err), file=stderr)
     exit(1)
 
 safe_mkdirs(path.dirname(args.o))