Skip to content

Commit

Permalink
Merge pull request #56 from jacobtomlinson/catch-skill-exceptions
Browse files Browse the repository at this point in the history
Catch skill exceptions
  • Loading branch information
jacobtomlinson committed Nov 17, 2016
2 parents 3f2369b + 210ea5a commit 717138a
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion opsdroid/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,11 +131,25 @@ def load_regex_skill(self, regex, skill):

async def parse(self, message):
"""Parse a string against all skills."""
# pylint: disable=broad-except
# We want to catch all exceptions coming from a skill module and not
# halt the application. If a skill throws an exception it just doesn't
# give a response to the user, so an error response should be given.
if message.text.strip() != "":
logging.debug("Parsing input: " + message.text)
for skill in self.skills:
if "regex" in skill:
regex = match(skill["regex"], message.text)
if regex:
message.regex = regex
await skill["skill"](self, message)
try:
await skill["skill"](self, message)
except Exception:
await message.respond(
"Whoops there has been an error")
await message.respond(
"Check the log for details")
logging.exception("Exception when parsing '" +
message.text +
"' against skill '" +
skill["regex"] + "'")

0 comments on commit 717138a

Please sign in to comment.