From f3d400d2dd45f11bb473d2a9b04216c04d20f2a3 Mon Sep 17 00:00:00 2001 From: Correl Roush Date: Mon, 4 Oct 2010 10:29:20 -0400 Subject: [PATCH] Raise an exception when a card cannot be found --- database.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/database.py b/database.py index 9003124..70fa506 100644 --- a/database.py +++ b/database.py @@ -16,7 +16,10 @@ class TextDB(Database): def __init__(self, filename): self.filename = filename def getCard(self, name): - return self.findCard(name).next() + try: + return self.findCard(name).next() + except: + raise Exception('Invalid card: {0}'.format(name)) def findCard(self, name=None): card = None with open(self.filename, 'r') as f: