Provide context for Nunjucks error
@param  {Error}    err Nunjucks error
@param  {string}   str string input for Nunjucks
@return {Error}    New error object with embedded context
function formatNunjucksError(err, input) {
  const match = err.message.match(/Line (\d+), Column \d+/);
  if (!match) return err;
  const errLine = parseInt(match[1], 10);
  if (isNaN(errLine)) return err;

  // trim useless info from Nunjucks Error
  const splited = err.message.replace('(unknown path)', '').split('\n');

  const e = new Error();
  e.name = 'Nunjucks Error';
  e.line = errLine;
  e.location = splited[0];
  e.type = splited[1].trim();
  e.message = getContext(input.split(/\r?\n/), errLine, e.location, e.type).join('\n');
  return e;
}