Skip to content

Commit

Permalink
Fix for getargs catching wrong TypeError.
Browse files Browse the repository at this point in the history
@getargs() now reraises the error if it is not a problem with arguments.
  • Loading branch information
natfarleydev committed May 17, 2017
1 parent 236ba30 commit b4bf310
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion skybeard/decorators/getargs.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,15 @@ async def g(beard, msg):
if "missing" in err_msg:
text = err_msg.replace("get_args() ", "")
text = text[0].upper() + text[1:]
else:
elif "takes" in err_msg:
args_expected, args_given = re.findall(r"\d", err_msg)
args_given = int(args_given) - 2
args_expected = int(args_expected) - 2
text = "Too many arguments given. (got {}, expected {})".format(
args_given, args_expected)
else:
# Else, it's not a problem with the function arguments
raise exception

await beard.sender.sendMessage(text)
return
Expand Down

0 comments on commit b4bf310

Please sign in to comment.