Skip to content

Commit

Permalink
adjust Exception types to be more logical
Browse files Browse the repository at this point in the history
  • Loading branch information
Bobspadger committed Apr 6, 2018
1 parent 9f383c5 commit a98bc2f
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions royal_mail_rest_api/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,25 +249,25 @@ def _add_service(self):

def add_service_format(self, format=None):
if format is None:
raise(KeyError('No service format selected'))
raise(ValueError('No service format selected'))
if format not in self.service_formats:
raise(ValueError('Invalid service format'))
raise(KeyError('Invalid service format'))
self.service_format = self.service_formats[format]


def add_service_type(self, service_type):
if service_type is None:
raise(KeyError('No service type selected'))
raise(Valueerror('no service type selected'))
if service_type not in self.service_types:
raise(ValueError('Invalid service type'))
raise(KeyError('Invalid service type'))
self.service_type = self.service_types[service_type]


def add_service_offering(self, service_offering):
if service_offering is None:
raise(KeyError('No service type selected'))
raise(ValueError('No service type selected'))
if service_offering not in self.service_offerings:
raise(ValueError('Invalid service type'))
raise(KeyError('Invalid service type'))
self.service_offering = self.service_offerings[service_offering]


Expand All @@ -280,14 +280,14 @@ def add_signature(self, signature=False):
if isinstance(signature, bool):
self.signature = signature
else:
raise(ValueError('Must be a boolean, True or False'))
raise(TypeError('Must be a boolean, True or False'))


def add_service_enhancements(self, enhancement):
if enhancement is None:
raise(KeyError('No Enhancement Selected'))
raise(ValueError('No Enhancement Selected'))
if enhancement not in self.service_enhancements:
raise(ValueError('Not in service_enhancements'))
raise(KeyError('Not in service_enhancements'))
self.enhancements.append(self.service_enhancements[enhancement])


Expand Down

0 comments on commit a98bc2f

Please sign in to comment.