diff options
author | Samy Pessé <samypesse@gmail.com> | 2015-04-02 18:59:56 +0200 |
---|---|---|
committer | Samy Pessé <samypesse@gmail.com> | 2015-04-02 18:59:56 +0200 |
commit | 0a94c80c4442d4a9ba5c5384eb854909ffa01f5e (patch) | |
tree | e201d8f8d20fdaafa37d644248f4897a7550a6e7 /lib/template.js | |
parent | c70bb2fbd8d2405547bc5a48205fd6cbeb6b32be (diff) | |
download | gitbook-0a94c80c4442d4a9ba5c5384eb854909ffa01f5e.zip gitbook-0a94c80c4442d4a9ba5c5384eb854909ffa01f5e.tar.gz gitbook-0a94c80c4442d4a9ba5c5384eb854909ffa01f5e.tar.bz2 |
Normalize template errors
Diffstat (limited to 'lib/template.js')
-rw-r--r-- | lib/template.js | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/template.js b/lib/template.js index 320c8bf..187df87 100644 --- a/lib/template.js +++ b/lib/template.js @@ -331,7 +331,13 @@ TemplateEngine.prototype.renderString = function(content, context, options) { // Replace shortcuts content = _.reduce(this.shortcuts, _.partial(this._applyShortcut.bind(this), options.type), content); - return Q.nfcall(this.env.renderString.bind(this.env), content, context, options); + return Q.nfcall(this.env.renderString.bind(this.env), content, context, options) + .fail(function(err) { + if (_.isString(err)) err = new Error(err); + err.message = err.message.replace(/^Error: /, ""); + + throw err; + }); }; // Render a file from the book |