Skip to content

Commit

Permalink
Merge pull request #21 from manhg/improve-error-message
Browse files Browse the repository at this point in the history
Log which expression broken along with data
  • Loading branch information
GianlucaGuarini committed May 6, 2017
2 parents 672b026 + 03cb8e8 commit 179bdd8
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/tmpl.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ var tmpl = (function () {
// the function (if it is not in the cache) and call it to replace expressions with
// their values. data (`this`) is a Tag instance, _logErr is the error handler.

return (_cache[str] || (_cache[str] = _create(str))).call(data, _logErr)
return (_cache[str] || (_cache[str] = _create(str))).call(
data, _logErr.bind({
data: data,
tmpl: str
})
)
}

/**
Expand Down Expand Up @@ -126,10 +131,9 @@ var tmpl = (function () {
typeof console !== 'undefined' &&
typeof console.error === 'function'
) {
if (err.riotData.tagName) {
console.error('Riot template error thrown in the <%s> tag', err.riotData.tagName)
}
console.error(err)
console.error(err.message)
console.log('<%s> %s', err.riotData.tagName || 'Unknown tag', this.tmpl) // eslint-disable-line
console.log(this.data) // eslint-disable-line
}
}

Expand Down

0 comments on commit 179bdd8

Please sign in to comment.