Class: Exceptify::SlackNotifier
- Inherits:
-
BaseNotifier
- Object
- BaseNotifier
- Exceptify::SlackNotifier
- Includes:
- BacktraceCleaner
- Defined in:
- lib/exceptify/slack_notifier.rb
Instance Attribute Summary collapse
-
#notifier ⇒ Object
Returns the value of attribute notifier.
Attributes inherited from BaseNotifier
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
-
#initialize(options) ⇒ SlackNotifier
constructor
A new instance of SlackNotifier.
Methods included from BacktraceCleaner
Methods inherited from BaseNotifier
#_post_callback, #_pre_callback, #send_notice
Constructor Details
#initialize(options) ⇒ SlackNotifier
Returns a new instance of SlackNotifier.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/exceptify/slack_notifier.rb', line 9 def initialize() = .dup fail_silently = .delete(:fail_silently) { false } injected_notifier = .delete(:notifier) super() self. = @ignore_data_if = [:ignore_data_if] @backtrace_lines = .fetch(:backtrace_lines, 10) @additional_fields = [:additional_fields] @message_opts = .fetch(:additional_parameters, {}).dup @color = @message_opts.delete(:color) { "danger" } @notifier = injected_notifier || build_notifier() rescue => e raise unless fail_silently log_configuration_error(e) @notifier = nil end |
Instance Attribute Details
#notifier ⇒ Object
Returns the value of attribute notifier.
7 8 9 |
# File 'lib/exceptify/slack_notifier.rb', line 7 def notifier @notifier end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/exceptify/slack_notifier.rb', line 30 def call(exception, = {}) notification = Notification.new(exception, , backtrace_cleaner: self) = exception..tr("`", "'") attchs = attchs(notification, ) return unless valid? args = [exception, , , @message_opts.merge(attachments: attchs)] send_notice(*args) do |_msg, | [:channel] = [:channel] if .key?(:channel) @notifier.ping "", end end |