Exception: Sass::CompileError

Inherits:
StandardError
  • Object
show all
Defined in:
lib/sass/exception.rb

Overview

An exception thrown because a Sass compilation failed.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#loaded_urlsArray<String> (readonly)

Returns:

  • (Array<String>)


13
14
15
# File 'lib/sass/exception.rb', line 13

def loaded_urls
  @loaded_urls
end

#sass_stackString? (readonly)

Returns:

  • (String, nil)


7
8
9
# File 'lib/sass/exception.rb', line 7

def sass_stack
  @sass_stack
end

#spanLogger::SourceSpan? (readonly)

Returns:



10
11
12
# File 'lib/sass/exception.rb', line 10

def span
  @span
end

Instance Method Details

#full_message(highlight: nil, order: nil) ⇒ String

Returns:

  • (String)


26
27
28
29
30
31
32
33
34
35
# File 'lib/sass/exception.rb', line 26

def full_message(highlight: nil, order: nil, **)
  return super if @full_message.nil?

  highlight = Exception.respond_to?(:to_tty?) && Exception.to_tty? if highlight.nil?
  if highlight
    @full_message.dup
  else
    @full_message.gsub(/\e\[[0-9;]*m/, '')
  end
end

#to_cssString

Returns:

  • (String)


38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/sass/exception.rb', line 38

def to_css
  content = full_message(highlight: false, order: :top)

  "    /* \#{content.gsub('*/', \"*\\u2060/\").gsub(\"\\r\\n\", \"\\n\").split(\"\\n\").join(\"\\n * \")} */\n\n    body::before {\n      position: static;\n      display: block;\n      padding: 1em;\n      margin: 0 0 1em;\n      border-width: 0 0 2px;\n      border-bottom-style: solid;\n      font-family: monospace, monospace;\n      white-space: pre;\n      content: \#{Serializer.serialize_quoted_string(content).gsub(/[^[:ascii:]][\\h\\t ]?/) do |match|\n        replacement = \"\\\\\#{match.ord.to_s(16)}\"\n        replacement << \" \#{match[1]}\" if match.length > 1\n        replacement\n      end};\n    }\n  CSS\nend\n".freeze