Skip to content

Commit 1f388d9

Browse files
author
Tim Vaillancourt
committed
making sure my custom exception gets caught with try/except
1 parent 6cbedbe commit 1f388d9

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

MongoBackup/Backup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,10 @@ def __init__(self, options):
7979
# Check for required fields:
8080
required = ['program_name', 'version', 'git_commit', 'backup_name', 'backup_binary', 'backup_location']
8181
for field in required:
82-
if not getattr(self, field):
83-
raise Exception, 'Field: %s is required by this class!', None
82+
try:
83+
getattr(self, field)
84+
except Exception:
85+
raise Exception, 'Field: %s is required by %s!' % (field, __name__), None
8486

8587
# Set default lock file:
8688
if not self.lock_file:

0 commit comments

Comments
 (0)