summaryrefslogtreecommitdiffstats
path: root/aurweb/exceptions.py
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2016-12-20 17:56:09 +0100
committerLukas Fleischer <lfleischer@archlinux.org>2016-12-23 20:05:05 +0100
commit8914a41db938194efc021f842c89d47ff6b522c9 (patch)
treec7b085362c6a8b61868e53d01d85559550f02255 /aurweb/exceptions.py
parent6d8edafe778809698246019c165b7c20b1e0afdf (diff)
downloadaur-8914a41db938194efc021f842c89d47ff6b522c9.tar.gz
aur-8914a41db938194efc021f842c89d47ff6b522c9.tar.xz
git-serve: Use Python exceptions for error handling
Make it easier to reuse the helper functions provided by git-serve from another Python script by throwing exceptions instead of terminating the program on errors. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'aurweb/exceptions.py')
-rw-r--r--aurweb/exceptions.py53
1 files changed, 53 insertions, 0 deletions
diff --git a/aurweb/exceptions.py b/aurweb/exceptions.py
new file mode 100644
index 00000000..5922b2df
--- /dev/null
+++ b/aurweb/exceptions.py
@@ -0,0 +1,53 @@
+class AurwebException(Exception):
+ pass
+
+
+class MaintenanceException(AurwebException):
+ pass
+
+
+class PermissionDeniedException(AurwebException):
+ def __init__(self, user):
+ msg = 'permission denied: {:s}'.format(user)
+ super(PermissionDeniedException, self).__init__(msg)
+
+
+class InvalidUserException(AurwebException):
+ def __init__(self, user):
+ msg = 'unknown user: {:s}'.format(user)
+ super(InvalidUserException, self).__init__(msg)
+
+
+class InvalidPackageBaseException(AurwebException):
+ def __init__(self, pkgbase):
+ msg = 'package base not found: {:s}'.format(pkgbase)
+ super(InvalidPackageBaseException, self).__init__(msg)
+
+
+class InvalidRepositoryNameException(AurwebException):
+ def __init__(self, pkgbase):
+ msg = 'invalid repository name: {:s}'.format(pkgbase)
+ super(InvalidRepositoryNameException, self).__init__(msg)
+
+
+class PackageBaseExistsException(AurwebException):
+ def __init__(self, pkgbase):
+ msg = 'package base already exists: {:s}'.format(pkgbase)
+ super(PackageBaseExistsException, self).__init__(msg)
+
+
+class InvalidReasonException(AurwebException):
+ def __init__(self, reason):
+ msg = 'invalid reason: {:s}'.format(reason)
+ super(InvalidReasonException, self).__init__(msg)
+
+
+class InvalidCommentException(AurwebException):
+ def __init__(self, comment):
+ msg = 'comment is too short: {:s}'.format(comment)
+ super(InvalidCommentException, self).__init__(msg)
+
+
+class InvalidArgumentsException(AurwebException):
+ def __init__(self, msg):
+ super(InvalidArgumentsException, self).__init__(msg)