Skip to content

Instantly share code, notes, and snippets.

@greenbigfrog
Created January 11, 2019 18:36
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 greenbigfrog/89e2edffaed65d8b0b9ae064c1ee3ea3 to your computer and use it in GitHub Desktop.
Save greenbigfrog/89e2edffaed65d8b0b9ae064c1ee3ea3 to your computer and use it in GitHub Desktop.
class ErrorCatcher
def call(payload, context)
yield
rescue ex
context[Discord::Client].create_message(payload.channel_id, "There was an unexpected error. This has been reported and should be resolved soon") unless ex == DB::PoolRetryAttemptsExceeded if payload.is_a?(Discord::Message)
puts ex.inspect_with_backtrace
# Truncate all payloads for now
Raven.capture(Exception.new("Exception while handling message #{payload.to_s[0..2000]}"))
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment