Skip to content
This repository

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
kares commented April 22, 2012

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

Showing 1 unique commit by 1 author.

Apr 16, 2012
Exceptions that include offending less filename and line number 4d368e7
This page is out of date. Refresh to see the latest.

Showing 1 changed file with 15 additions and 2 deletions. Show diff stats Hide diff stats

  1. 17  lib/less/parser.rb
17  lib/less/parser.rb
@@ -100,13 +100,26 @@ class ParseError < StandardError
100 100
     # Copies over `error`'s message and backtrace
101 101
     # @param [V8::JSError] error native error
102 102
     def initialize(error)
103  
-      super(error.message)
104  
-      @backtrace = error.backtrace
  103
+      @line = error.value.line if error.value.respond_to? :line
  104
+      @filename = error.value.filename if error.value.respond_to? :filename
  105
+      @message = error.message
  106
+      
  107
+      super(self.full_message)
  108
+      
  109
+      @backtrace = error.backtrace      
105 110
     end
106 111
 
107 112
     # @return [Array] the backtrace frames
108 113
     def backtrace
109 114
       @backtrace
110 115
     end
  116
+
  117
+    def full_message
  118
+      if @line && @filename
  119
+        "Error at #{@filename}:#{@line} - #{@message}"
  120
+      else
  121
+        @message
  122
+      end
  123
+    end
111 124
   end
112 125
 end
Commit_comment_tip

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.