From 68eb84c0bbaade1f4d6fd54f869f665c97bd3cc2 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sat, 14 Feb 2004 01:02:53 +0000 Subject: [PATCH] Better error handling on open. --- src/ircdb.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/ircdb.py b/src/ircdb.py index 0c5097032..755df2dc0 100644 --- a/src/ircdb.py +++ b/src/ircdb.py @@ -516,7 +516,11 @@ class UsersDictionary(utils.IterableMap): def open(self, filename): self.filename = filename reader = unpreserve.Reader(IrcUserCreator, self) - reader.readFile(filename) + try: + reader.readFile(filename) + except Exception, e: + log.error('Invalid user dictionary file, starting from scratch.') + log.error('Exact error: %s', utils.exnToString(e)) def reload(self): """Reloads the database from its file.""" @@ -675,7 +679,11 @@ class ChannelsDictionary(utils.IterableMap): def open(self, filename): self.filename = filename reader = unpreserve.Reader(IrcChannelCreator, self) - reader.readFile(filename) + try: + reader.readFile(filename) + except Exception, e: + log.error('Invalid channel database, starting from scratch.') + log.error('Exact error: %s', utils.exnToString(e)) def flush(self): """Flushes the channel database to its file."""