-
-
Notifications
You must be signed in to change notification settings - Fork 194
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3931470
commit 1aff534
Showing
8 changed files
with
69 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
class LessError extends Error { | ||
constructor(error) { | ||
super(); | ||
|
||
this.message = [ | ||
'\n', | ||
...LessError.getFileExcerptIfPossible(error), | ||
error.message.charAt(0).toUpperCase() + error.message.slice(1), | ||
` Error in ${error.filename} (line ${error.line}, column ${error.column})`, | ||
].join('\n'); | ||
|
||
this.hideStack = true; | ||
} | ||
|
||
static getFileExcerptIfPossible(lessErr) { | ||
if (lessErr.extract === 'undefined') { | ||
return []; | ||
} | ||
|
||
const excerpt = lessErr.extract.slice(0, 2); | ||
const column = Math.max(lessErr.column - 1, 0); | ||
|
||
if (typeof excerpt[0] === 'undefined') { | ||
excerpt.shift(); | ||
} | ||
|
||
excerpt.push(`${new Array(column).join(' ')}^`); | ||
|
||
return excerpt; | ||
} | ||
} | ||
|
||
export default LessError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters