No commit activity in last 3 years
No release in over 3 years
Wrap your code in our block and let us send error messages when you screw up.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.10
~> 10.0

Runtime

 Project Readme

Slack Error Notifier

Simple Slack exception notification for Ruby scripts. Just wrap your code in SlackErrorNotifier.with_notifications {} and off you go.

Installation

Add this line to your application's Gemfile:

gem 'slack_error_notifier'

And then execute:

$ bundle

Or install it yourself as:

$ gem install slack_error_notifier

Usage

Configuration

SlackErrorNotifier.configuration do |config|
  config.app_name = <THE NAME OF YOUR APP OR SCRIPT>
  config.access_token = <YOUR SLACK TOKEN>
  config.target_channel = <THE CHANNEL OR USER TO POST MESSAGES TO> # include '@' or '#' as applicable
  confg.send_as_user = <TRUE/FALSE> # whether you want to send as slackbot or the user whose token you're using.   
end

Pro-tip: Add a bot to your Slack organization and then use its API Token. You can then configure the avatar and username you want messages to come from.

Catching Exceptions in Your Code

SlackErrorNotifier.with_notifications do 
  # Commence dangerous operations here:
  NuclearLaunchCode.run!
end

Your target user or channel will then be notified of any unhandled exceptions that occur during the dangerous operation.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/cgrdavies/slack_error_notifier. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.