linkedin / dustjs

Asynchronous Javascript templating for the browser and server
http://dustjs.com
MIT License
2.91k stars 478 forks source link

Thrown exception instead of returning error #774

Open Sembiance opened 7 years ago

Sembiance commented 7 years ago

The following code throws an uncaught exception:

require("dustjs-linkedin").renderSource("{T}{/T}", {}, function(e, r) { });

Shouldn't dust be catching this exception and passing it into the callback as the first parameter as an error?

/home/sembiance/tmp/dustjs_error/node_modules/dustjs-linkedin/lib/compiler.js:34
      throw new SyntaxError(err.message + ' At line : ' + err.line + ', column : ' + err.column);
      ^

SyntaxError: Expected buffer, comment, end of input, partial, raw, reference, section or special but "{" found. At line : 1, column : 4
    at Object.compiler.compile (/home/sembiance/tmp/dustjs_error/node_modules/dustjs-linkedin/lib/compiler.js:34:13)
    at Object.renderSource (/home/sembiance/tmp/dustjs_error/node_modules/dustjs-linkedin/lib/compiler.js:440:37)
    at Object.<anonymous> (/home/sembiance/tmp/dustjs_error/test.js:1:90)
    at Module._compile (module.js:569:30)
    at Object.Module._extensions..js (module.js:580:10)
    at Module.load (module.js:503:32)
    at tryModuleLoad (module.js:466:12)
    at Function.Module._load (module.js:458:3)
    at Function.Module.runMain (module.js:605:10)
    at startup (bootstrap_node.js:158:16)