Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

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

  • Loading branch information...
commit 29dcbb8856c36e358ba0f8d0e8e907ae3d828abe 1 parent 1af334b
Richo Healey richo authored

Showing 2 changed files with 6 additions and 7 deletions. Show diff stats Hide diff stats

  1. +4 5 config.py
  2. +2 2 pyBawt.py
9 config.py
@@ -53,7 +53,7 @@ def passthru(val):
53 53 continue
54 54 try:
55 55 key, value = map(lambda x: x.strip(),line.split('=', 1))
56   - config[key] = value
  56 + config[key] = (value, lineno)
57 57 except ValueError:
58 58 raise InvalidConfig, "Invalid key value pair at line %i" % (lineno)
59 59 except IOError:
@@ -65,12 +65,11 @@ def passthru(val):
65 65 for name, transformer in keys:
66 66 __all__.append(name)
67 67 try:
68   - # This is fucked XXX FIXME
69   - #__dict__[name] = transformer(config[name])
70   - exec('%s = %s' % (name, repr(transformer(config[name]))))
  68 + val, line = config[name]
  69 + exec('%s = %s' % (name, repr(transformer(val))))
71 70
72 71 except ValueError: #Probably port didn't translate
73 72 # Pull lineno, spit out useful error
74   - raise InvalidConfig
  73 + raise InvalidConfig, "Counldn't parse %s on line %i" % (val, line)
75 74 except KeyError: #Didn't have a required key
76 75 raise InvalidConfig, "Missing required key: %s" % (name)
4 pyBawt.py
@@ -15,8 +15,8 @@
15 15 import logging
16 16 try:
17 17 import config
18   -except InvalidConfig:
19   - logging.fatal("Couldn't load config file")
  18 +except InvalidConfig as e:
  19 + logging.fatal("Couldn't load config file: %s" % (str(e)))
20 20
21 21 import ircSocket
22 22 import time

0 comments on commit 29dcbb8

Please sign in to comment.
Something went wrong with that request. Please try again.