From 42f9ea9bfcf90b339f322a8925719dc7af2944f0 Mon Sep 17 00:00:00 2001 From: Jeremy Fincher Date: Sun, 3 Oct 2004 09:39:39 +0000 Subject: [PATCH] Let's catch some exceptions and continue with the output-writing if an exception is raised. --- src/registry.py | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/registry.py b/src/registry.py index 391c0e09d..b5b02a25c 100644 --- a/src/registry.py +++ b/src/registry.py @@ -39,6 +39,14 @@ import textwrap import supybot.fix as fix import supybot.utils as utils +def error(s): + """Replace me with something better from another module!""" + print '***', s + +def exception(s): + """Ditto!""" + print '***', s, 'A bad exception.' + class RegistryException(Exception): pass @@ -101,11 +109,18 @@ def close(registry, filename, annotated=True, helpOnceOnly=False): if value._showDefault: lines.append('#\n') x = value.__class__(value._default, value._help) - lines.append('# Default value: %s\n' % x) + try: + lines.append('# Default value: %s\n' % x) + except Exception, e: + exception('Exception printing default value:') lines.append('###\n') fd.writelines(lines) if hasattr(value, 'value'): # This lets us print help for non-valued. - fd.write('%s: %s\n' % (name, value.serialize())) + try: + fd.write('%s: %s\n' % (name, value.serialize())) + except Exception, e: + exception('Exception printing value:') + fd.close() def isValidRegistryName(name):