Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Line and filename of exception #27

Open
wants to merge 1 commit into from

2 participants

tzeskimo Karol Bucek
tzeskimo

Adds less filename and line number to exceptions. Makes debugging a large project much easier. FYI, The specs still pass, but I've only tested this with a single exception.

Karol Bucek
Collaborator

I've tried adding info from JS LessError as well at: kares@e180955#L0R32 at pull #26

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Apr 16, 2012
This page is out of date. Refresh to see the latest.
Showing with 15 additions and 2 deletions.
  1. +15 −2 lib/less/parser.rb
17 lib/less/parser.rb
View
@@ -100,13 +100,26 @@ class ParseError < StandardError
# Copies over `error`'s message and backtrace
# @param [V8::JSError] error native error
def initialize(error)
- super(error.message)
- @backtrace = error.backtrace
+ @line = error.value.line if error.value.respond_to? :line
+ @filename = error.value.filename if error.value.respond_to? :filename
+ @message = error.message
+
+ super(self.full_message)
+
+ @backtrace = error.backtrace
end
# @return [Array] the backtrace frames
def backtrace
@backtrace
end
+
+ def full_message
+ if @line && @filename
+ "Error at #{@filename}:#{@line} - #{@message}"
+ else
+ @message
+ end
+ end
end
end
Something went wrong with that request. Please try again.