Exception: Less::Error

Inherits:
StandardError
  • Object
show all
Defined in:
lib/less/errors.rb

Direct Known Subclasses

ParseError

Instance Method Summary collapse

Constructor Details

#initialize(cause, value = nil) ⇒ Error

Returns a new instance of Error.



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/less/errors.rb', line 5

def initialize(cause, value = nil)
  @value = value
  message = nil
  if @value # 2 args passed
    message = @value['message']
  else # allow passing only value as first arg cause :
    if cause.respond_to?(:'[]') && message = cause['message']
      @value = cause
    end
  end
  
  if cause.is_a?(::Exception)
    @cause = cause
    super(message || cause.message)
  else
    super(message || cause)
  end
end

Instance Method Details

#backtraceObject



28
29
30
# File 'lib/less/errors.rb', line 28

def backtrace
  @cause ? @cause.backtrace : super
end

#causeObject



24
25
26
# File 'lib/less/errors.rb', line 24

def cause
  @cause
end