Sha256: e7c3de395c9035e3028c43063fc6785613cb51a4931028018a6a09cbca20d8db

Contents?: true

Size: 697 Bytes

Versions: 7

Compression:

Stored size: 697 Bytes

Contents

module BugHunter
  class Middleware
    def initialize(app)
      @app = app
    end

    def call(env)
      response = nil
      begin
        response = @app.call(env)
      rescue StandardError, LoadError, SyntaxError => e
        error = BugHunter::Error.build_from(env, e)

        if !error.valid? && !error.errors[:uniqueness].empty?
          BugHunter::Error.collection.update(error.unique_error_selector,
                                             {:$inc => {:times => 1}, :$set => {:updated_at => Time.now.utc}},
                                             {:multi => true})
        else
          error.save
        end

        raise e
      end

      response
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
bug_hunter-0.1.1 lib/bug_hunter/middleware.rb
bug_hunter-0.1.0 lib/bug_hunter/middleware.rb
bug_hunter-0.0.6 lib/bug_hunter/middleware.rb
bug_hunter-0.0.5 lib/bug_hunter/middleware.rb
bug_hunter-0.0.4 lib/bug_hunter/middleware.rb
bug_hunter-0.0.2 lib/bug_hunter/middleware.rb
bug_hunter-0.0.1 lib/bug_hunter/middleware.rb