linkedin/dustjs — pull request #495 by sethkinast (2014-09-03 00:29:23+00:00)
Title: Catch syntax errors in context and fail gracefully

Reviving #267 with un-bitrotted code.

This catches three cases where errors in context functions would bomb execution:
1) `_get` would try to execute functions from the context. If they fail, it return `dust.log()`, which returns `undefined`.
2) `map()` would try to execute a callback, but the callback could throw.
3) sections can be functions that are executed, but the functions could throw.

All of these now log an ERROR level, and call `setError()` on their chunk.

The easiest way to see the effect is to introduce a syntax error into one of the test cases. The `dust.render()` callback will never be invoked, which cripples many Node-based implementations that use Dust rendering, since they just spin forever.

I did introduce another change in this PR: if tests are expecting an error, they now pass if the expected value is contained within the error, instead of checking equality. This is because PhantomJS has different errors compared to a browser.