Sha256: d637c1e410269d01d9f6ef6f5ff6657d7b6c4933e6ed7631a51ede06e91fb3ae

Contents?: true

Size: 714 Bytes

Versions: 17

Compression:

Stored size: 714 Bytes

Contents

module Locomotive::Steam

  class NoSiteException < ::Exception
  end

  class RenderError < ::StandardError

    LINES_RANGE = 10

    attr_reader :file, :source, :line, :original_backtrace

    def initialize(message, file, source, line, original_backtrace)
      @file, @source, @line, @original_backtrace = file, source, line, original_backtrace
      super(message)
    end

    def code_lines
      return [] if source.blank? || line.nil?

      lines = source.split("\n")

      start   = line - (LINES_RANGE / 2)
      start   = 0 if start < 0
      finish  = line + (LINES_RANGE / 2)

      (start..finish).map { |i| [i, lines[i]] }
    end

    def backtrace
      original_backtrace
    end

  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
locomotivecms_steam-1.1.2 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.1.1 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.1.0 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.1.0.rc3 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.1.0.rc2 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.1.0.rc1 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.1 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0.rc10 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0.rc9 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0.rc8 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0.rc6 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0.rc4 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0.rc3 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0.rc2 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0.rc1 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.0.0.pre.beta.3 lib/locomotive/steam/errors.rb