Skip to content

Commit

Permalink
Issue #153: better feedback to user in the case of an invalid format …
Browse files Browse the repository at this point in the history
…name
  • Loading branch information
kpdyer committed Oct 8, 2014
1 parent 9a813f7 commit d2bc4af
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion fteproxy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ class NegotiateTimeoutException(Exception):
def fatal_error(msg):
if fteproxy.conf.getValue('runtime.loglevel') in [1,2,3]:
print 'ERROR:', msg
traceback.print_stack()
sys.exit(1)


Expand Down
12 changes: 10 additions & 2 deletions fteproxy/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,11 +144,19 @@ def run(self):
fteproxy.warn('Failed to write PID file to disk: '+pid_file)

if fteproxy.conf.getValue('runtime.mode') == 'client':
incoming_regex = fteproxy.defs.getRegex(self._args.downstream_format)
try:
incoming_regex = fteproxy.defs.getRegex(self._args.downstream_format)
except fteproxy.defs.InvalidRegexName:
fteproxy.fatal_error('Invalid format name '+self._args.downstream_format)

incoming_fixed_slice = fteproxy.defs.getFixedSlice(
self._args.downstream_format)
fte.encoder.DfaEncoder(fteproxy.regex2dfa.regex2dfa(incoming_regex), incoming_fixed_slice)
outgoing_regex = fteproxy.defs.getRegex(self._args.upstream_format)
try:
outgoing_regex = fteproxy.defs.getRegex(self._args.upstream_format)
except InvalidRegexName:
fteproxy.fatal_error('Invalid format name '+self._args.upstream_format)

outgoing_fixed_slice = fteproxy.defs.getFixedSlice(
self._args.upstream_format)
fte.encoder.DfaEncoder(fteproxy.regex2dfa.regex2dfa(outgoing_regex), outgoing_fixed_slice)
Expand Down

0 comments on commit d2bc4af

Please sign in to comment.