1 -class CoprHttpException(Exception): 2 3 _default = "Generic copr exception" 4 _code = 500 5 6 - def __init__(self, message=None, code=None, **kwargs): 7 self.message = message 8 self.code = code or self._code 9 self.kwargs = kwargs 10 11 - def __unicode__(self): 12 return self.message or self._default 13 14 - def __str__(self): 15 return self.__unicode__() 16 17 18 -class ObjectNotFound(CoprHttpException): 19 20 _default = "Requested object was not found" 21 _code = 404 22 23 24 -class AccessRestricted(CoprHttpException): 25 26 _default = "You don't have required permission" 27 _code = 403 28 29 30 -class BadRequest(CoprHttpException): 31 32 _default = "Bad request to the server" 33 _code = 400 34 35 36 -class LegacyApiError(CoprHttpException): 37 38 _default = "API error" 39 _code = 500 40 41 42 -class MalformedArgumentException(ValueError): 43 pass 44 45 46 -class NotFoundException(ObjectNotFound): 47 pass 48 49 50 -class DuplicateException(BadRequest): 51 pass 52 53 54 -class NonAdminCannotCreatePersistentProject(CoprHttpException): 55 _default = "Non-admin cannot create persistent project." 56 _code = 403 57 58 59 -class NonAdminCannotDisableAutoPrunning(CoprHttpException): 60 _default = "Non-admin cannot disable auto-prunning." 61 _code = 403 62 63 InsufficientRightsException = AccessRestricted 64 65 66 -class RequestCannotBeExecuted(CoprHttpException): 67 pass 68 69 70 -class ActionInProgressException(CoprHttpException): 71 72 - def __init__(self, msg, action): 73 self.msg = msg 74 self.action = action 75 76 - def __unicode__(self): 77 return self.formatted_msg() 78 79 - def __str__(self): 80 return self.__unicode__() 81 82 - def formatted_msg(self): 83 return self.msg.format(action=self.action) 84 85 86 -class UnknownSourceTypeException(Exception): 87 pass 88 89 -class NoPackageSourceException(Exception): 90 pass 91