Sha256: 265754b2317c64e8c89291f7cb2a0a5925ee76bcfbe7a9bf61a161093707111e

Contents?: true

Size: 973 Bytes

Versions: 4

Compression:

Stored size: 973 Bytes

Contents

module RailsLiveDashboard
  module Recorders
    class ExceptionRecorder
      def initialize(exception)
        @exception = exception
      end

      def execute
        Exception.of_class(@exception.class).update_all(should_show: false)

        Exception.create(
          batch_id: RailsLiveDashboard::Context.instance.batch_id,
          content: build_content
        )
      end

      private

      def build_content
        occurrences = Exception.of_class(@exception.class).count

        {
          class: @exception.class,
          message: @exception.message,
          file: file_line[0],
          line: file_line[1],
          backtrace: @exception.backtrace,
          occurrences: occurrences + 1
        }
      end

      def file_line
        return ['', ''] unless @exception.backtrace

        file = @exception.backtrace[0].split(':').first
        line = @exception.backtrace[0].split(':')[1]

        [file, line]
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_live_dashboard-0.2.0 lib/rails_live_dashboard/recorders/exception_recorder.rb
rails_live_dashboard-0.1.2 lib/rails_live_dashboard/recorders/exception_recorder.rb
rails_live_dashboard-0.1.1 lib/rails_live_dashboard/recorders/exception_recorder.rb
rails_live_dashboard-0.1.0 lib/rails_live_dashboard/recorders/exception_recorder.rb