2019-10-21 08:21:32 +00:00
|
|
|
import mishards.exception_codes as codes
|
|
|
|
|
|
|
|
|
|
|
|
class BaseException(Exception):
|
|
|
|
code = codes.INVALID_CODE
|
|
|
|
message = 'BaseException'
|
|
|
|
|
|
|
|
def __init__(self, message='', metadata=None):
|
|
|
|
self.message = self.__class__.__name__ if not message else message
|
|
|
|
self.metadata = metadata
|
|
|
|
|
2020-04-25 12:40:30 +00:00
|
|
|
def __repr__(self):
|
|
|
|
return self.message
|
|
|
|
|
|
|
|
__str__ = __repr__
|
|
|
|
|
2019-10-21 08:21:32 +00:00
|
|
|
|
|
|
|
class ConnectionConnectError(BaseException):
|
|
|
|
code = codes.CONNECT_ERROR_CODE
|
|
|
|
|
|
|
|
|
|
|
|
class ConnectionNotFoundError(BaseException):
|
|
|
|
code = codes.CONNECTTION_NOT_FOUND_CODE
|
|
|
|
|
|
|
|
|
|
|
|
class DBError(BaseException):
|
|
|
|
code = codes.DB_ERROR_CODE
|
|
|
|
|
|
|
|
|
2020-04-15 13:32:20 +00:00
|
|
|
class CollectionNotFoundError(BaseException):
|
|
|
|
code = codes.COLLECTION_NOT_FOUND_CODE
|
2019-10-21 08:21:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
class InvalidTopKError(BaseException):
|
|
|
|
code = codes.INVALID_TOPK_CODE
|
|
|
|
|
|
|
|
|
2020-03-20 12:21:11 +00:00
|
|
|
class SearchParamError(BaseException):
|
|
|
|
code = codes.SEARCH_PARAM_LOSS_CODE
|
|
|
|
|
|
|
|
|
2019-10-21 08:21:32 +00:00
|
|
|
class InvalidArgumentError(BaseException):
|
|
|
|
code = codes.INVALID_ARGUMENT_CODE
|
|
|
|
|
|
|
|
|
|
|
|
class InvalidRangeError(BaseException):
|
|
|
|
code = codes.INVALID_DATE_RANGE_CODE
|