Exception handling improvements

* Replace some prints with proper logging messages
* Make VCSException as verbose as BuildException, including error output
This commit is contained in:
Daniel Martí 2014-07-02 15:30:05 +02:00
parent c64aafaf42
commit d132adf63c
4 changed files with 47 additions and 46 deletions

View file

@ -1050,20 +1050,23 @@ def main():
logfile.write(str(be))
logfile.close()
reason = str(be).split('\n', 1)[0] if options.verbose else str(be)
print("Could not build app %s due to BuildException: %s" % (
logging.error("Could not build app %s due to BuildException: %s" % (
app['id'], reason))
if options.stop:
sys.exit(1)
failed_apps[app['id']] = be
wikilog = be.get_wikitext()
except VCSException as vcse:
print("VCS error while building app %s: %s" % (app['id'], vcse))
reason = str(vcse).split('\n', 1)[0] if options.verbose else str(vcse)
logging.error("VCS error while building app %s: %s" % (
app['id'], reason))
if options.stop:
sys.exit(1)
failed_apps[app['id']] = vcse
wikilog = str(vcse)
except Exception as e:
print("Could not build app %s due to unknown error: %s" % (app['id'], traceback.format_exc()))
logging.error("Could not build app %s due to unknown error: %s" % (
app['id'], traceback.format_exc()))
if options.stop:
sys.exit(1)
failed_apps[app['id']] = e