Make use of FDroidException in the main fdroid script

This should improve the output shown when exceptions are found
This commit is contained in:
Daniel Martí 2014-07-03 13:59:36 +02:00
parent d9d5f30d7b
commit 73142c740b
2 changed files with 14 additions and 5 deletions

13
fdroid
View File

@ -21,6 +21,8 @@
import sys
import logging
from fdroidserver.common import FDroidException
commands = {
"build": "Build a package from source",
"init": "Quickly start a new repository",
@ -83,14 +85,21 @@ def main():
del sys.argv[1]
mod = __import__('fdroidserver.' + command, None, None, [command])
try:
mod.main()
except Exception, e:
# These are ours, contain a proper message and are "expected"
except FDroidException, e:
if verbose:
raise
else:
print str(e)
logging.critical(str(e))
sys.exit(1)
# These should only be unexpected crashes due to bugs in the code
# str(e) often doesn't contain a reason, so just show the backtrace
except Exception, e:
logging.critical("Unknown exception found!")
raise
sys.exit(0)
if __name__ == "__main__":

View File

@ -971,7 +971,7 @@ def parse_androidmanifests(paths, ignoreversions=None):
return (max_version, max_vercode, max_package)
class _FDroidException(Exception):
class FDroidException(Exception):
def __init__(self, value, detail=None):
self.value = value
self.detail = detail
@ -993,11 +993,11 @@ class _FDroidException(Exception):
return ret
class VCSException(_FDroidException):
class VCSException(FDroidException):
pass
class BuildException(_FDroidException):
class BuildException(FDroidException):
pass