Skip to content

Commit

Permalink
@getargs() now only acts on decorated fn TypeError
Browse files Browse the repository at this point in the history
  • Loading branch information
natfarleydev committed May 17, 2017
1 parent b4bf310 commit 635b1e8
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions skybeard/decorators/getargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ async def g(beard, msg):
except TypeError as exception:
# TODO have configurable messages when args are not enough
err_msg = exception.args[0]
if "missing" in err_msg:
if err_msg.startswith(f.__name__+"() missing"):
text = err_msg.replace("get_args() ", "")
text = text[0].upper() + text[1:]
elif "takes" in err_msg:
elif err_msg.startswith(f.__name__+"() takes"):
args_expected, args_given = re.findall(r"\d", err_msg)
args_given = int(args_given) - 2
args_expected = int(args_expected) - 2
Expand All @@ -40,6 +40,7 @@ async def g(beard, msg):
# Else, it's not a problem with the function arguments
raise exception

beard.logger.debug("Exception message was: {}".format(err_msg))
await beard.sender.sendMessage(text)
return

Expand Down

0 comments on commit 635b1e8

Please sign in to comment.