Skip to content

Commit

Permalink
Refactor custom errors (#249)
Browse files Browse the repository at this point in the history
* Refactor custom errors

* Change custom exception message function name to avoid conflict

* Remove unnecessary ex in InvalidConfigError

* Update version to 0.12.0rc2

* Update error message
  • Loading branch information
SLdragon authored Dec 4, 2019
1 parent 84213b6 commit da64f1e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 14 deletions.
2 changes: 1 addition & 1 deletion iotedgehubdev/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
pkg_resources.declare_namespace(__name__)

__author__ = 'Microsoft Corporation'
__version__ = '0.12.0rc1'
__version__ = '0.12.0rc2'
__AIkey__ = '95b20d64-f54f-4de3-8ad5-165a75a6c6fe'
__production__ = 'iotedgehubdev'
2 changes: 1 addition & 1 deletion iotedgehubdev/edgemanager.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def start_solution(self, module_content, verbose, output):
try:
EdgeManager.login_registries(module_content)
except RegistriesLoginError as e:
output.warning(e.message())
output.warning(e.getmsg())

edgedockerclient = EdgeDockerClient()
mount_base = self._obtain_mount_path(edgedockerclient)
Expand Down
19 changes: 8 additions & 11 deletions iotedgehubdev/errors.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,26 @@ def __init__(self, msg, ex=None):
super(EdgeDeploymentError, self).__init__(msg, ex)


class ResponseError(Exception):
class ResponseError(EdgeError):
def __init__(self, status_code, value):
super(ResponseError, self).__init__('Code:{0}. Detail:{1}'.format(status_code, value))
self.value = value
self.status_code = status_code

def message(self):
return ('Code:{0}. Detail:{1}').format(self.status_code, self.value)

def status(self):
return self.status_code


class RegistriesLoginError(Exception):
class RegistriesLoginError(EdgeError):
def __init__(self, registries, errmsg):
super(RegistriesLoginError, self).__init__(errmsg)
self._registries = registries
self._errmsg = errmsg

def message(self):
def getmsg(self):
return ('Fail to login {0}. Detail: {1}').format(self._registries, self._errmsg)

def registries(self):
return self._registries


class InvalidConfigError(Exception):
pass
class InvalidConfigError(EdgeError):
def __init__(self, msg):
super(InvalidConfigError, self).__init__(msg)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"""
from setuptools import find_packages, setup

VERSION = '0.12.0rc1'
VERSION = '0.12.0rc2'
# If we have source, validate that our version numbers match
# This should prevent uploading releases with mismatched versions.
try:
Expand Down

0 comments on commit da64f1e

Please sign in to comment.