Class: RailsErrorNotifier::Notifier
- Inherits:
-
Object
- Object
- RailsErrorNotifier::Notifier
- Defined in:
- lib/rails_error_notifier/notifier.rb
Constant Summary collapse
- MAX_FIELD_VALUE =
1024
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#exception ⇒ Object
readonly
Returns the value of attribute exception.
Instance Method Summary collapse
- #deliver ⇒ Object
-
#initialize(exception, context = {}) ⇒ Notifier
constructor
A new instance of Notifier.
Constructor Details
#initialize(exception, context = {}) ⇒ Notifier
Returns a new instance of Notifier.
16 17 18 19 |
# File 'lib/rails_error_notifier/notifier.rb', line 16 def initialize(exception, context = {}) @exception = exception @context = context end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
14 15 16 |
# File 'lib/rails_error_notifier/notifier.rb', line 14 def context @context end |
#exception ⇒ Object (readonly)
Returns the value of attribute exception.
14 15 16 |
# File 'lib/rails_error_notifier/notifier.rb', line 14 def exception @exception end |
Instance Method Details
#deliver ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
# File 'lib/rails_error_notifier/notifier.rb', line 21 def deliver return unless RailsErrorNotifier.configuration&.enabled app_trace = (exception.backtrace || []).select { |line| line.to_s.include?("/app/") } payload = { error: exception., backtrace: app_trace.presence || exception.backtrace || ["No backtrace"], context: context || {} } # Slack + Discord send_to_webhook(RailsErrorNotifier.configuration.slack_webhook, payload) send_to_webhook(RailsErrorNotifier.configuration.discord_webhook, payload) # Email (Rails Mailer) send_to_email(payload) # WhatsApp (Twilio) send_to_whatsapp(payload) end |