Skip to content

Instantly share code, notes, and snippets.

@martinstreicher
Created September 28, 2017 20:52
Show Gist options
  • Save martinstreicher/98ae3a3b4514856ec4ffd70b07487bc7 to your computer and use it in GitHub Desktop.
Save martinstreicher/98ae3a3b4514856ec4ffd70b07487bc7 to your computer and use it in GitHub Desktop.

Revisions

  1. martinstreicher renamed this gist Sep 28, 2017. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  2. martinstreicher created this gist Sep 28, 2017.
    23 changes: 23 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    module Middleware
    SquelchedException = Class.new Exception

    class SidekiqExceptionHandler
    def call(worker, job, queue)
    yield
    rescue Exception => exception
    notify exception, job, ignore: ignore_exception?(exception)
    raise SquelchedException
    end

    private

    def ignore_exception?(exception)
    Bugsnag.configuration.ignore_classes.include?(exception.class.name)
    end

    def notify(exception, job, ignore: false)
    args = job['args'].inject { |result, hash| result.merge hash }
    ExceptionLoggingService.log(exception, args: args, ignore: ignore)
    end
    end
    end