Skip to content

Commit f695a04

Browse files
authored
fix: error.showSourceCode is not a function (#196)
Fixes #196
1 parent 569a9bb commit f695a04

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/parser/index.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ module.exports = async css => {
2121
return Promise.resolve(processNodes(rootNode))
2222
} catch (error) {
2323
const {line, column, reason} = error
24+
const message = error.showSourceCode
25+
? `${reason} at line ${line}, column ${column}:\n\n${error.showSourceCode(
26+
false
27+
)}`
28+
: `${reason} at line ${line}, column ${column}:\n\n${error.source}`
2429

25-
return Promise.reject(
26-
new SyntaxError(
27-
`${reason} at line ${line}, column ${column}:\n\n${error.showSourceCode(
28-
false
29-
)}`
30-
)
31-
)
30+
return Promise.reject(new SyntaxError(message))
3231
}
3332
}

0 commit comments

Comments
 (0)