class ExceptionHunter::Notifiers::SlackNotifier

Notifier that sends a message to a Slack channel every time an exception is tracked.

Attributes

error[R]
notifier[R]

Public Class Methods

new(error, notifier) click to toggle source
# File lib/exception_hunter/notifiers/slack_notifier.rb, line 10
def initialize(error, notifier)
  @error = error
  @notifier = notifier
end

Public Instance Methods

notify() click to toggle source
# File lib/exception_hunter/notifiers/slack_notifier.rb, line 15
def notify
  slack_notifier = Slack::Notifier.new(notifier[:options][:webhook])
  slack_notifier.ping(slack_notification_message)
end

Private Instance Methods

error_message() click to toggle source
# File lib/exception_hunter/notifiers/slack_notifier.rb, line 36
def error_message
  "*#{error.class_name}*: #{error.message}. \n" \
    "<#{ExceptionHunter::Engine.routes.url_helpers.error_url(error.error_group)}|Click to see the error>"
end
slack_notification_message() click to toggle source
# File lib/exception_hunter/notifiers/slack_notifier.rb, line 22
def slack_notification_message
  {
    blocks: [
      {
        type: 'section',
        text: {
          type: 'mrkdwn',
          text: error_message
        }
      }
    ]
  }
end