Avoid treating quota exception as bug exception

This commit is contained in:
Mario de Frutos
2018-02-01 18:21:15 +01:00
parent b260c29b8c
commit 0df0b0d49c
3 changed files with 15 additions and 4 deletions

View File

@@ -3,5 +3,5 @@ from coordinates import Coordinate
from polyline import PolyLine
from log import Logger, LoggerConfig
from rate_limiter import RateLimiter
from service_manager import ServiceManager, RateLimitExceeded
from service_manager import ServiceManager, RateLimitExceeded, QuotaExceededException
from legacy_service_manager import LegacyServiceManager

View File

@@ -10,6 +10,10 @@ class RateLimitExceeded(Exception):
def __str__(self):
return repr('Rate limit exceeded')
class QuotaExceededException(Exception):
def __str__(self):
return repr('You have reached the limit of your quota')
class ServiceManagerBase:
"""
@@ -37,7 +41,7 @@ class ServiceManagerBase:
if rate and not self.rate_limiter.check():
raise RateLimitExceeded()
if quota and not self.quota_service.check_user_quota():
raise Exception('You have reached the limit of your quota')
raise QuotaExceededException()
@property
def config(self):