Class: ExceptionNotifier::TalkNotifier
- Inherits:
-
Object
- Object
- ExceptionNotifier::TalkNotifier
- Includes:
- BacktraceCleaner
- Defined in:
- lib/exception_notifier/talk_notifier.rb
Instance Method Summary collapse
- #call(exception, options = {}) ⇒ Object
-
#initialize(options) ⇒ TalkNotifier
constructor
A new instance of TalkNotifier.
- #stringify_exception(e) ⇒ Object
Constructor Details
#initialize(options) ⇒ TalkNotifier
8 9 10 11 12 13 |
# File 'lib/exception_notifier/talk_notifier.rb', line 8 def initialize() = [:author_name] || Socket.gethostname @backtrace_depth = [:backtrace_depth] @clean_backtrace = [:clean_backtrace] @hook_url = [:hook_url] end |
Instance Method Details
#call(exception, options = {}) ⇒ Object
15 16 17 18 19 20 21 |
# File 'lib/exception_notifier/talk_notifier.rb', line 15 def call(exception, ={}) Faraday.post(@hook_url, { authorName: , title: "#{exception.class.name}: #{exception.message}", text: stringify_exception(exception) }) end |
#stringify_exception(e) ⇒ Object
23 24 25 26 27 28 29 30 31 |
# File 'lib/exception_notifier/talk_notifier.rb', line 23 def stringify_exception(e) if e.backtrace.present? backtrace = @clean_backtrace ? clean_backtrace(e) : e.backtrace backtrace = backtrace.first(@backtrace_depth) if @backtrace_depth ["#{e.class.name}: #{e.message}", 'Backtrace: ', backtrace].join("\n") else "#{e.class.name}: #{e.message}" end end |