Skip to content

Commit

Permalink
feat: location specific syntax dust errors for #150
Browse files Browse the repository at this point in the history
  • Loading branch information
David Longworth committed Apr 12, 2017
1 parent 79758e7 commit 00b9563
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions dadi/lib/dust/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,22 @@ const Dust = function () {
}

if (!this.templates[name]) {
return callback({message: 'Template not found: ' + name}, null)
return callback({name: 'File missing', message: 'Template not found: ' + name}, null)
}

var compiled = dust.compile(this.templates[name])
var tmpl = dust.loadSource(compiled)
var rendered = true

return callback(null, tmpl)
try {
var compiled = dust.compile(this.templates[name], name)
} catch (err) {
rendered = false
return callback({name: 'SyntaxError', message: 'Error compiling template: ' + name, stack: err.stack}, null)
}

if (rendered) {
var tmpl = dust.loadSource(compiled)
return callback(null, tmpl)
}
}
}

Expand Down

0 comments on commit 00b9563

Please sign in to comment.