Catch exceptions in rule matching