mirror of
https://github.com/f-droid/fdroidserver.git
synced 2025-09-14 06:52:39 +03:00
Replace sys.exit() in non-main functions by exceptions
Also move all exceptions into one module
This commit is contained in:
parent
a8420817cb
commit
1fcd8e63a3
17 changed files with 119 additions and 141 deletions
44
fdroidserver/exception.py
Normal file
44
fdroidserver/exception.py
Normal file
|
@ -0,0 +1,44 @@
|
|||
class FDroidException(Exception):
|
||||
|
||||
def __init__(self, value=None, detail=None):
|
||||
self.value = value
|
||||
self.detail = detail
|
||||
|
||||
def shortened_detail(self):
|
||||
if len(self.detail) < 16000:
|
||||
return self.detail
|
||||
return '[...]\n' + self.detail[-16000:]
|
||||
|
||||
def get_wikitext(self):
|
||||
ret = repr(self.value) + "\n"
|
||||
if self.detail:
|
||||
ret += "=detail=\n"
|
||||
ret += "<pre>\n" + self.shortened_detail() + "</pre>\n"
|
||||
return ret
|
||||
|
||||
def __str__(self):
|
||||
ret = self.value
|
||||
if self.detail:
|
||||
ret += "\n==== detail begin ====\n%s\n==== detail end ====" % self.detail.strip()
|
||||
return ret
|
||||
|
||||
|
||||
class MetaDataException(Exception):
|
||||
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
def __str__(self):
|
||||
return self.value
|
||||
|
||||
|
||||
class VCSException(FDroidException):
|
||||
pass
|
||||
|
||||
|
||||
class BuildException(FDroidException):
|
||||
pass
|
||||
|
||||
|
||||
class VerificationException(FDroidException):
|
||||
pass
|
Loading…
Add table
Add a link
Reference in a new issue