Permalink
Browse files

Spit out useful error message when we have to bail on config

  • Loading branch information...
richo committed Sep 28, 2011
1 parent 365e885 commit f32b2e5f92860bd391bebc62d3b573407f21ae2a
Showing with 6 additions and 7 deletions.
  1. +4 −5 config.py
  2. +2 −2 pyBawt.py
View
@@ -53,7 +53,7 @@ def passthru(val):
continue
try:
key, value = map(lambda x: x.strip(),line.split('=', 1))
- config[key] = value
+ config[key] = (value, lineno)
except ValueError:
raise InvalidConfig, "Invalid key value pair at line %i" % (lineno)
except IOError:
@@ -65,12 +65,11 @@ def passthru(val):
for name, transformer in keys:
__all__.append(name)
try:
- # This is fucked XXX FIXME
- #__dict__[name] = transformer(config[name])
- exec('%s = %s' % (name, repr(transformer(config[name]))))
+ val, line = config[name]
+ exec('%s = %s' % (name, repr(transformer(val))))
except ValueError: #Probably port didn't translate
# Pull lineno, spit out useful error
- raise InvalidConfig
+ raise InvalidConfig, "Counldn't parse %s on line %i" % (val, line)
except KeyError: #Didn't have a required key
raise InvalidConfig, "Missing required key: %s" % (name)
View
@@ -15,8 +15,8 @@
import logging
try:
import config
-except InvalidConfig:
- logging.fatal("Couldn't load config file")
+except InvalidConfig as e:
+ logging.fatal("Couldn't load config file: %s" % (str(e)))
import ircSocket
import time

0 comments on commit f32b2e5

Please sign in to comment.