Sha256: 9fb698d92375bc4ab2cd05f411079563b7846900e0d83fa9ac71d711d728bf50

Contents?: true

Size: 1.25 KB

Versions: 8

Compression:

Stored size: 1.25 KB

Contents

module Liquid
  class Error < ::StandardError
    attr_accessor :line_number
    attr_accessor :template_name
    attr_accessor :markup_context

    def to_s(with_prefix = true)
      str = ""
      str << message_prefix if with_prefix
      str << super()

      if markup_context
        str << " "
        str << markup_context
      end

      str
    end

    private

    def message_prefix
      str = ""
      if is_a?(SyntaxError)
        str << "Liquid syntax error"
      else
        str << "Liquid error"
      end

      if line_number
        str << " ("
        str << template_name << " " if template_name
        str << "line " << line_number.to_s << ")"
      end

      str << ": "
      str
    end
  end

  ArgumentError = Class.new(Error)
  ContextError = Class.new(Error)
  FileSystemError = Class.new(Error)
  StandardError = Class.new(Error)
  SyntaxError = Class.new(Error)
  StackLevelError = Class.new(Error)
  TaintedError = Class.new(Error)
  MemoryError = Class.new(Error)
  ZeroDivisionError = Class.new(Error)
  FloatDomainError = Class.new(Error)
  UndefinedVariable = Class.new(Error)
  UndefinedDropMethod = Class.new(Error)
  UndefinedFilter = Class.new(Error)
  MethodOverrideError = Class.new(Error)
  InternalError = Class.new(Error)
end

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
liquid-4.0.4 lib/liquid/errors.rb
metanorma-cli-1.3.4 gems/ruby/2.6.0/gems/liquid-4.0.3/lib/liquid/errors.rb
metanorma-cli-1.3.3.1 gems/ruby/2.6.0/gems/liquid-4.0.3/lib/liquid/errors.rb
liquid-4.0.3 lib/liquid/errors.rb
liquid-4.0.2 lib/liquid/errors.rb
liquid-4-0-2-4.0.2 lib/liquid/errors.rb
liquid-4.0.1 lib/liquid/errors.rb
liquid-4.0.0 lib/liquid/errors.rb