8000 Display the error instead of the traceback (notify.slack) by fabaff · Pull Request #3079 · home-assistant/core · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
8000

Display the error instead of the traceback (notify.slack) #3079

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 2 commits into from
Sep 3, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 16 additions & 10 deletions homeassistant/components/notify/slack.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,33 @@
"""
import logging

from homeassistant.components.notify import DOMAIN, BaseNotificationService
import voluptuous as vol

from homeassistant.components.notify import (
PLATFORM_SCHEMA, BaseNotificationService)
from homeassistant.const import CONF_API_KEY
from homeassistant.helpers import validate_config
import homeassistant.helpers.config_validation as cv

REQUIREMENTS = ['slacker==0.9.24']

_LOGGER = logging.getLogger(__name__)

CONF_CHANNEL = 'default_channel'

PLATFORM_SCHEMA = PLATFORM_SCHEMA.extend({
vol.Required(CONF_API_KEY): cv.string,
vol.Required(CONF_CHANNEL): cv.string,
})


# pylint: disable=unused-variable
def get_service(hass, config):
"""Get the Slack notification service."""
import slacker

if not validate_config({DOMAIN: config},
{DOMAIN: ['default_channel', CONF_API_KEY]},
_LOGGER):
return None

try:
return SlackNotificationService(
config['default_channel'],
config[CONF_CHANNEL],
config[CONF_API_KEY])

except slacker.Error:
Expand Down Expand Up @@ -61,5 +67,5 @@ def send_message(self, message="", **kwargs):
self.slack.chat.post_message(channel, message,
as_user=True,
attachments=attachments)
except slacker.Error:
_LOGGER.exception("Could not send slack notification")
except slacker.Error as err:
_LOGGER.error("Could not send slack notification. Error: %s", err)
0