Sha256: 06b1cece3d00bf5ecd03c4119c6c679169598314f1bd6cd8a9c4a5953f8b0090

Contents?: true

Size: 740 Bytes

Versions: 3

Compression:

Stored size: 740 Bytes

Contents

module Houston

  # Rescues exceptions and reports them
  def self.async
    Thread.new do
      ActiveRecord::Base.connection_pool.with_connection do
        begin
          yield
        rescue Exception # rescues StandardError by default; but we want to rescue and report all errors
          Houston.report_exception($!)
        ensure
          Rails.logger.flush # http://stackoverflow.com/a/3516003/731300
        end
      end
    end
  end

  # Allows exceptions to bubble up
  def self.async!
    Thread.new do
      ActiveRecord::Base.connection_pool.with_connection do
        begin
          yield
        ensure
          Rails.logger.flush # http://stackoverflow.com/a/3516003/731300
        end
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
houston-core-0.7.0.beta3 config/initializers/houston_async.rb
houston-core-0.7.0.beta2 config/initializers/houston_async.rb
houston-core-0.7.0.beta config/initializers/houston_async.rb