archive
/
Printr
Archived
1
Fork 0

Added error

This commit is contained in:
Jake Howard 2015-09-26 21:50:36 +01:00
parent 3f8a9ca11c
commit 1c6cefcfba
1 changed files with 11 additions and 2 deletions

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():
def __init__(self, string, maxValue, start, diff=1):
self.string = string
@ -8,7 +14,10 @@ class ItterPrintr():
self.buildString()
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):
return self.maxValue <= self.value
@ -20,4 +29,4 @@ class ItterPrintr():
self.inc()
def inc(self):
self.value += self.diff
self.value += self.diff