Sha256: 529ea8e824eaee705bc318df0ad31136ade7006910473a05fddaf844c9c86b35

Contents?: true

Size: 1.46 KB

Versions: 17

Compression:

Stored size: 1.46 KB

Contents

module Sass
  # Sass::SyntaxError encapsulates information about the exception,
  # such as the line of the Sass template it was raised on
  # and the Sass file that was being parsed (if applicable).
  # It also provides a handy way to rescue only exceptions raised
  # because of a faulty template.
  class SyntaxError < StandardError
    # The line of the Sass template on which the exception was thrown.
    attr_accessor :sass_line

    # The name of the file that was being parsed when the exception was raised.
    # This will be nil unless Sass is being used as an ActionView plugin.
    attr_reader :sass_filename

    # Creates a new SyntaxError.
    # +lineno+ should be the line of the Sass template on which the error occurred.
    def initialize(msg, lineno = nil)
      @message = msg
      @sass_line = lineno
    end

    # Add information about the filename and line on which the error was raised.
    def add_metadata(filename, line)
      self.sass_line ||= line
      add_backtrace_entry(filename) unless sass_filename
      raise self
    end

    # Adds a properly formatted entry to the exception's backtrace.
    # +filename+ should be the file in which the error occurred,
    # if applicable (defaults to "(sass)").
    def add_backtrace_entry(filename) # :nodoc:
      @sass_filename ||= filename
      self.backtrace ||= []
      self.backtrace.unshift "#{@sass_filename || '(sass)'}:#{@sass_line}"
    end

    def to_s # :nodoc:
      @message
    end
  end
end

Version data entries

17 entries across 17 versions & 2 rubygems

Version Path
gohanlonllc-haml-2.1.0.20080513000000 lib/sass/error.rb
gohanlonllc-haml-2.1.0 lib/sass/error.rb
haml-edge-2.1.12 lib/sass/error.rb
haml-edge-2.1.10 lib/sass/error.rb
haml-edge-2.1.11 lib/sass/error.rb
haml-edge-2.1.13 lib/sass/error.rb
haml-edge-2.1.16 lib/sass/error.rb
haml-edge-2.1.17 lib/sass/error.rb
haml-edge-2.1.18 lib/sass/error.rb
haml-edge-2.1.19 lib/sass/error.rb
haml-edge-2.1.20 lib/sass/error.rb
haml-edge-2.1.21 lib/sass/error.rb
haml-edge-2.1.14 lib/sass/error.rb
haml-edge-2.1.15 lib/sass/error.rb
haml-edge-2.1.9 lib/sass/error.rb
haml-edge-2.1.7 lib/sass/error.rb
haml-edge-2.1.8 lib/sass/error.rb