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
This commit is contained in:
committed by
Gerrit Code Review
parent
6fb2c4d8e0
commit
9d9d68f2bb
@@ -125,8 +125,12 @@ if not path.exists(cache_ent):
|
|||||||
safe_mkdirs(path.dirname(cache_ent))
|
safe_mkdirs(path.dirname(cache_ent))
|
||||||
print('Download %s' % src_url, file=stderr)
|
print('Download %s' % src_url, file=stderr)
|
||||||
check_call(['curl', '--proxy-anyauth', '-sfo', cache_ent, src_url])
|
check_call(['curl', '--proxy-anyauth', '-sfo', cache_ent, src_url])
|
||||||
except (OSError, CalledProcessError) as err:
|
except OSError as err:
|
||||||
print('error using curl: %s' % str(err), file=stderr)
|
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)
|
exit(1)
|
||||||
|
|
||||||
if args.v:
|
if args.v:
|
||||||
@@ -153,7 +157,7 @@ if args.exclude_java_sources:
|
|||||||
finally:
|
finally:
|
||||||
zf.close()
|
zf.close()
|
||||||
except (BadZipfile, LargeZipFile) as err:
|
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)
|
exit(1)
|
||||||
|
|
||||||
safe_mkdirs(path.dirname(args.o))
|
safe_mkdirs(path.dirname(args.o))
|
||||||
|
|||||||
Reference in New Issue
Block a user