diff --git a/lib/index.js b/lib/index.js index 6d59b93..e89c89e 100644 --- a/lib/index.js +++ b/lib/index.js @@ -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]; @@ -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