Created
October 27, 2015 21:47
-
-
Save danielberndt/8ee83eb1a05ffde37887 to your computer and use it in GitHub Desktop.
sending exceptions straight to slack
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'slack-notifier' | |
slack_notifier = Slack::Notifier.new HOOKURL, username: 'oh-noes' | |
rescue_from :all do |e| | |
attachment = { | |
fallback: "stacktrace", | |
color: "danger", | |
fields: e.backtrace.map {|line| {value: slack_notifier.escape(line), short: false}} | |
} | |
slack_notifier.ping "#{e.class.name}: #{e.message}", attachments: [attachment], icon_emoji: ":scream:" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment