Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def checkAndRaise(pageNum, itemsPerPage):
"""Check and Raise an Exception if needed
Args:
pageNum (int): Page number
itemsPerPage (int): Number of items per Page
Raises:
ErrPaginationLimits: If we are out of limits
"""
if pageNum < 1:
raise ErrPaginationLimits(ErrPaginationLimits.ERR_PAGE_NUM)
if itemsPerPage < Settings.itemsPerPageMin or itemsPerPage > Settings.itemsPerPageMax:
raise ErrPaginationLimits(ErrPaginationLimits.ERR_ITEMS_PER_PAGE)
def __init__(self, error_code):
if error_code == ErrPaginationLimits.ERR_PAGE_NUM:
super().__init__("pageNum can't be smaller than 1")
elif error_code == ErrPaginationLimits.ERR_ITEMS_PER_PAGE:
super().__init__("itemsPerPage can't be smaller than %d and greater than %d" % (
Settings.itemsPerPageMin, Settings.itemsPerPageMax))
else:
super().__init__(str(error_code))
def __init__(self, error_code):
if error_code == ErrPaginationLimits.ERR_PAGE_NUM:
super().__init__("pageNum can't be smaller than 1")
elif error_code == ErrPaginationLimits.ERR_ITEMS_PER_PAGE:
super().__init__("itemsPerPage can't be smaller than %d and greater than %d" % (
Settings.itemsPerPageMin, Settings.itemsPerPageMax))
else:
super().__init__(str(error_code))
def checkAndRaise(pageNum, itemsPerPage):
"""Check and Raise an Exception if needed
Args:
pageNum (int): Page number
itemsPerPage (int): Number of items per Page
Raises:
ErrPaginationLimits: If we are out of limits
"""
if pageNum < 1:
raise ErrPaginationLimits(ErrPaginationLimits.ERR_PAGE_NUM)
if itemsPerPage < Settings.itemsPerPageMin or itemsPerPage > Settings.itemsPerPageMax:
raise ErrPaginationLimits(ErrPaginationLimits.ERR_ITEMS_PER_PAGE)