Added error
This commit is contained in:
parent
3f8a9ca11c
commit
1c6cefcfba
1 changed files with 11 additions and 2 deletions
|
@ -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):
|
||||||
|
try:
|
||||||
return self.string.format(c=self.value, m=self.maxValue)
|
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
|
||||||
|
|
Reference in a new issue