Skip to content

Instantly share code, notes, and snippets.

@danielberndt
Created October 27, 2015 21:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save danielberndt/8ee83eb1a05ffde37887 to your computer and use it in GitHub Desktop.
Save danielberndt/8ee83eb1a05ffde37887 to your computer and use it in GitHub Desktop.
sending exceptions straight to slack
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