8000 Catch exceptions by fabaff · Pull Request #9085 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Catch exceptions #9085

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 23, 2017
Merged

Catch exceptions #9085

merged 3 commits into from
Aug 23, 2017

Conversation

fabaff
Copy link
Member
@fabaff fabaff commented Aug 22, 2017

Description:

Catch exceptions if target is not specified or wrong.

Example entry for configuration.yaml (if applicable):

notifiy:
  - name: discord
    platform: discord
    token: !secret discord

Message sent with "Call Service"

{
  "message": "The sun is {% if is_state('sun.sun', 'above_horizon') %}up{% else %}down{% endif %}!",
  "target": [
    "331133124211638272"
    ]
}

Checklist:

If the code communicates with devices, web services, or third-party tools:

  • Local tests with tox run successfully. Your PR cannot be merged unless tests pass

discord.errors.NotFound) as error:
_LOGGER.warning("Communication error: %s", error)
# pylint: disable=broad-except
except KeyError:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which access can result it KeyError?

If kwargs[ATTR_TARGET] then it can be checked in the beginning of async_send_message.

@balloob balloob merged commit 2355216 into dev Aug 23, 2017
@balloob balloob deleted the keyerror-discord branch August 23, 2017 05:21
@balloob balloob mentioned this pull request Aug 25, 2017
@home-assistant home-assistant locked and limited conversation to collaborators Dec 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants
0