UNPKG

968 BJavaScriptView Raw
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.default = void 0;
7
8class CssSyntaxError extends Error {
9 constructor(error) {
10 super(error);
11 const {
12 reason,
13 line,
14 column,
15 file
16 } = error;
17 this.name = "CssSyntaxError"; // Based on https://github.com/postcss/postcss/blob/master/lib/css-syntax-error.es6#L132
18 // We don't need `plugin` and `file` properties.
19
20 this.message = `${this.name}\n\n`;
21
22 if (typeof line !== "undefined") {
23 this.message += `(${line}:${column}) `;
24 }
25
26 this.message += file ? `${file} ` : "<css input> ";
27 this.message += `${reason}`;
28 const code = error.showSourceCode();
29
30 if (code) {
31 this.message += `\n\n${code}\n`;
32 } // We don't need stack https://github.com/postcss/postcss/blob/master/docs/guidelines/runner.md#31-dont-show-js-stack-for-csssyntaxerror
33
34
35 this.stack = false;
36 }
37
38}
39
40exports.default = CssSyntaxError;
\No newline at end of file