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
  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
# File 'lib/sass/exception.rb', line 38

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

  <<~CSS
    /* #{message.gsub('*/', "*\u2060/").gsub("\r\n", "\n").split("\n").join("\n * ")} */

    body::before {
      position: static;
      display: block;
      padding: 1em;
      margin: 0 0 1em;
      border-width: 0 0 2px;
      border-bottom-style: solid;
      font-family: monospace, monospace;
      white-space: pre;
      content: #{Serializer.dump_quoted_string(message)};
    }
  CSS
end