Exception: Sass::SyntaxError
- Defined in:
- lib/sass/error.rb
Overview
An exception class that keeps track of the line of the Sass template it was raised on and the Sass file that was being parsed (if applicable).
All Sass errors are raised as SyntaxErrors.
Instance Attribute Summary collapse
-
#sass_filename ⇒ String
readonly
The name of the file that was being parsed when the exception was raised.
-
#sass_line ⇒ Fixnum
The line of the Sass template on which the error occurred.
Instance Method Summary collapse
-
#add_backtrace_entry(filename) ⇒ Object
Adds a properly formatted entry to the exception’s backtrace.
-
#add_metadata(filename, line) ⇒ Object
Add information about the filename and line on which the error was raised, and re-raises the exception.
-
#initialize(msg, lineno = nil) ⇒ SyntaxError
constructor
A new instance of SyntaxError.
-
#to_s ⇒ String
The error message.
Constructor Details
#initialize(msg, lineno = nil) ⇒ SyntaxError
Returns a new instance of SyntaxError.
21 22 23 24 |
# File 'lib/sass/error.rb', line 21 def initialize(msg, lineno = nil) @message = msg @sass_line = lineno end |
Instance Attribute Details
#sass_filename ⇒ String (readonly)
The name of the file that was being parsed when the exception was raised. This could be ‘nil` if no filename is available.
17 18 19 |
# File 'lib/sass/error.rb', line 17 def sass_filename @sass_filename end |
#sass_line ⇒ Fixnum
The line of the Sass template on which the error occurred.
11 12 13 |
# File 'lib/sass/error.rb', line 11 def sass_line @sass_line end |
Instance Method Details
#add_backtrace_entry(filename) ⇒ Object
Adds a properly formatted entry to the exception’s backtrace.
42 43 44 45 46 |
# File 'lib/sass/error.rb', line 42 def add_backtrace_entry(filename) # :nodoc: @sass_filename ||= filename self.backtrace ||= [] self.backtrace.unshift "#{@sass_filename || '(sass)'}:#{@sass_line}" end |
#add_metadata(filename, line) ⇒ Object
Add information about the filename and line on which the error was raised, and re-raises the exception.
32 33 34 35 36 |
# File 'lib/sass/error.rb', line 32 def (filename, line) self.sass_line ||= line add_backtrace_entry(filename) unless sass_filename raise self end |
#to_s ⇒ String
Returns The error message.
49 50 51 |
# File 'lib/sass/error.rb', line 49 def to_s @message end |