Skip to content

Commit

Permalink
housekeeping: enhance trace reporting for AST composition errors (via s…
Browse files Browse the repository at this point in the history
…wagger-api#1997)

* unrelated lockfile updates

* bump minimum `bundlesize` version

* generate new lockfile trees for `karma` and `webpack`

* enhance trace reporting for AST composition errors
  • Loading branch information
shockey authored May 23, 2019
1 parent ab36e18 commit 018bfe5
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/plugins/ast/ast.js
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,15 @@ export function pathForPosition(yaml, position) {
var ast = cachedCompose(yaml)
} catch (e) {
console.error("Error composing AST", e)
console.error(`Problem area:\n`, yaml.split("\n").slice(position.line - 5, position.line + 5).join("\n"))

const problemMark = e.problem_mark || {}
const errorTraceMessage = [
yaml.split("\n").slice(problemMark.line - 5, problemMark.line).join("\n"),
Array(problemMark.column).fill(" ").join("") + `^----- ${e.name}: ${e.toString().split("\n")[0]}`,
yaml.split("\n").slice(problemMark.line + 1, problemMark.line + 5).join("\n")
].join("\n")

console.error(errorTraceMessage)
return null
}

Expand Down

0 comments on commit 018bfe5

Please sign in to comment.