Sha256: 05c35b83120c1d52f0d44c1c40fba9f01996470f537f4d8f274938a068e3c7da

Contents?: true

Size: 1.78 KB

Versions: 1

Compression:

Stored size: 1.78 KB

Contents

require 'ro_rails_helpers'

module RubymineHeaven
  module LinkableErrors

    def self.included(base)
      base.class_eval do

        private

        def link_to_code(text)
          ::RoRailsHelpers::Handler.link_to_code(text)
          # we must create new String, because SafeBuffer#gsub don't set $1, $2, ... variables !!
          #String.new(text).gsub(/(\/?[\w\/\.@-]+)\:(\d+)/) do |match|
          #  file = $1 || "file??"
          #  line = $2 || "line-no??"
          #  file = Rails.root + file if file =~ Rails::BacktraceCleaner::APP_DIRS_PATTERN
          #  "<a href='x-mine://open?file=#{file}&line=#{line}'>#{match}</a>"
          #end
        end

        def render_exception(env, exception)

          begin
            wrapper = ActionDispatch::ExceptionWrapper.new(env, exception)
            log_error(env, wrapper)

            if env['action_dispatch.show_detailed_exceptions']
              template = ActionView::Base.new(\
              [::ActionDispatch::DebugExceptions::RESCUES_TEMPLATE_PATH],
              :request => ActionDispatch::Request.new(env),
              :exception => wrapper.exception,
              :application_trace => wrapper.application_trace,
              :framework_trace => wrapper.framework_trace,
              :full_trace => wrapper.full_trace
              )

              file = "rescues/#{wrapper.rescue_template}"
              body = template.render(:template => file, :layout => 'rescues/layout')
              body = link_to_code(body)

              render(wrapper.status_code, body)
            else
              raise exception
            end
          rescue => e
            ::Rails.logger.error e
            e.backtrace.each do |b|
              ::Rails.logger.error b
            end
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
rrjj-0.0.1 lib/rubymine_heaven/linkable_errors.rb