chiark / gitweb /
scanner: rename variables, use os.path.relpath
[fdroidserver.git] / fdroidserver / exception.py
1 class FDroidException(Exception):
2
3     def __init__(self, value=None, detail=None):
4         self.value = value
5         self.detail = detail
6
7     def shortened_detail(self):
8         if len(self.detail) < 16000:
9             return self.detail
10         return '[...]\n' + self.detail[-16000:]
11
12     def get_wikitext(self):
13         ret = repr(self.value) + "\n"
14         if self.detail:
15             ret += "=detail=\n"
16             ret += "<pre>\n" + self.shortened_detail() + "</pre>\n"
17         return ret
18
19     def __str__(self):
20         ret = self.value
21         if self.detail:
22             ret += "\n==== detail begin ====\n%s\n==== detail end ====" % self.detail.strip()
23         return ret
24
25
26 class MetaDataException(Exception):
27
28     def __init__(self, value):
29         self.value = value
30
31     def __str__(self):
32         return self.value
33
34
35 class VCSException(FDroidException):
36     pass
37
38
39 class BuildException(FDroidException):
40     pass
41
42
43 class VerificationException(FDroidException):
44     pass