Raise an exception when a card cannot be found

This commit is contained in:
Correl Roush 2010-10-04 10:29:20 -04:00
parent fa5cf52120
commit f3d400d2dd

View file

@ -16,7 +16,10 @@ class TextDB(Database):
def __init__(self, filename): def __init__(self, filename):
self.filename = filename self.filename = filename
def getCard(self, name): def getCard(self, name):
try:
return self.findCard(name).next() return self.findCard(name).next()
except:
raise Exception('Invalid card: {0}'.format(name))
def findCard(self, name=None): def findCard(self, name=None):
card = None card = None
with open(self.filename, 'r') as f: with open(self.filename, 'r') as f: