Added error

This commit is contained in:
Jake Howard 2015-09-26 21:50:36 +01:00
parent 3f8a9ca11c
commit 1c6cefcfba

View file

@ -1,3 +1,9 @@
class FormattingException(Exception):
message = "Provided string doesn't contain formatting placeholders for {c} and/or {m}"
def __init__(self):
super().__init__(self.message)
class ItterPrintr(): class ItterPrintr():
def __init__(self, string, maxValue, start, diff=1): def __init__(self, string, maxValue, start, diff=1):
self.string = string self.string = string
@ -8,7 +14,10 @@ class ItterPrintr():
self.buildString() self.buildString()
def buildString(self): def buildString(self):
return self.string.format(c=self.value, m=self.maxValue) try:
return self.string.format(c=self.value, m=self.maxValue)
except:
raise FormattingError()
def reachedLimit(self): def reachedLimit(self):
return self.maxValue <= self.value return self.maxValue <= self.value