Sha256: e4d7c4505875d29d11cbd5cedb1a15576f808fdde2154012369fa3afd747c7fd

Contents?: true

Size: 759 Bytes

Versions: 6

Compression:

Stored size: 759 Bytes

Contents

module Locomotive::Steam

  class NoSiteException < ::Exception
  end

  class ActionException < ::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

6 entries across 6 versions & 1 rubygems

Version Path
locomotivecms_steam-1.2.1 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.2.0 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.2.0.rc3 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.2.0.rc2 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.2.0.rc1 lib/locomotive/steam/errors.rb
locomotivecms_steam-1.2.0.beta1 lib/locomotive/steam/errors.rb