Skip to content

Commit

Permalink
Add current file name to error message (#164)
Browse files Browse the repository at this point in the history
  • Loading branch information
mpalpha authored and ismay committed Apr 7, 2019
1 parent c969c6e commit 8d9c102
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function getTransformer(ext) {
*/

function render({ filename, files, metadata, engineOptions }) {
return new Promise(resolve => {
return new Promise((resolve, reject) => {
const [base, ...extensions] = filename.split('.');
const file = files[filename];

Expand Down Expand Up @@ -57,7 +57,12 @@ function render({ filename, files, metadata, engineOptions }) {

// Transform the contents
debug(`rendering ${ext} extension for ${filename}`);
file.contents = transform.render(file.contents, engineOptions, locals).body;
try {
file.contents = transform.render(file.contents, engineOptions, locals).body;
} catch (err) {
err.message = `${filename}: ${err.message}`;
return reject(err);
}
}

// Store results and delete old file
Expand Down

0 comments on commit 8d9c102

Please sign in to comment.