Sha256: 54864a05c9de713dd60fbfe1863e1c80f5bd5a1f35a45c937ac0c2bb30e58613

Contents?: true

Size: 936 Bytes

Versions: 2

Compression:

Stored size: 936 Bytes

Contents

module Errdo
  module Models
    class SlackMessager

      include Errdo::Helpers::ViewsHelper # For the naming of the user in the message

      def initialize(error, parser)
        if error.nil?
          @user = parser.user
          @backtrace = parser.short_backtrace
          @exception_name = parser.exception_name
          @exception_message = parser.exception_message
        else
          @user = error.last_experiencer
          @backtrace = error.short_backtrace
          @exception_name = error.exception_class_name
          @exception_message = error.exception_message
        end
      end

      def message
        "#{exception_string}#{user_message_addon}\n#{@backtrace}"
      end

      private

      def exception_string
        "#{@exception_name} | #{@exception_message}"
      end

      def user_message_addon
        "\nExperienced by #{user_show_string(@user)} " if @user
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
errdo-0.9.1 lib/errdo/models/slack_messager.rb
errdo-0.9.0 lib/errdo/models/slack_messager.rb