Skip to content

Commit

Permalink
Add file and line number to @mdx/loader error output
Browse files Browse the repository at this point in the history
  • Loading branch information
Jocelyn Badgley committed Sep 5, 2022
1 parent 996771a commit 5e1d896
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions packages/loader/lib/index.js
Expand Up @@ -62,10 +62,19 @@ export function loader(value, callback) {
map.set(hash, process)
}

process({value, path: this.resourcePath}).then((file) => {
callback(null, file.value, file.map)
return file
}, callback)
process({value, path: this.resourcePath}).then(
(file) => {
callback(null, file.value, file.map)
},
(e) => {
let loc = '';
if (e.position) {
loc = `:${e.position.start.line}:${e.position.start.column}`;
}
e.message = `${e.message} while parsing ${this.resourcePath}${loc}`;
callback(e);
}
)
}

/**
Expand Down

0 comments on commit 5e1d896

Please sign in to comment.