Refactored exception name to a more specific one

This commit is contained in:
VakarisZ 2020-10-15 15:19:19 +03:00
parent 7abafb70e1
commit a77743137f
2 changed files with 5 additions and 5 deletions

View File

@ -22,5 +22,5 @@ class AlreadyRegisteredError(RegistrationNotNeededError):
""" Raise to indicate the reason why registration is not required """
class NoInternetError(Exception):
""" Raise to indicate problems caused when no internet connection is present"""
class VersionServerConnectionError(Exception):
""" Raise to indicate that connection to version update server failed """

View File

@ -3,7 +3,7 @@ import logging
import requests
import monkey_island.cc.environment.environment_singleton as env_singleton
from common.utils.exceptions import NoInternetError
from common.utils.exceptions import VersionServerConnectionError
from common.version import get_version
__author__ = "itay.mizeretz"
@ -30,7 +30,7 @@ class VersionUpdateService:
if VersionUpdateService.newer_version is None:
try:
VersionUpdateService.newer_version = VersionUpdateService._check_new_version()
except NoInternetError:
except VersionServerConnectionError:
logger.info('Failed updating version number')
return VersionUpdateService.newer_version
@ -47,7 +47,7 @@ class VersionUpdateService:
reply = requests.get(url, timeout=7)
except requests.exceptions.RequestException:
logger.info("Can't get latest monkey version, probably no connection to the internet.")
raise NoInternetError
raise VersionServerConnectionError
res = reply.json().get('newer_version', None)