summaryrefslogtreecommitdiffstats
path: root/lib/template.js
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2015-04-02 18:59:56 +0200
committerSamy Pessé <samypesse@gmail.com>2015-04-02 18:59:56 +0200
commit0a94c80c4442d4a9ba5c5384eb854909ffa01f5e (patch)
treee201d8f8d20fdaafa37d644248f4897a7550a6e7 /lib/template.js
parentc70bb2fbd8d2405547bc5a48205fd6cbeb6b32be (diff)
downloadgitbook-0a94c80c4442d4a9ba5c5384eb854909ffa01f5e.zip
gitbook-0a94c80c4442d4a9ba5c5384eb854909ffa01f5e.tar.gz
gitbook-0a94c80c4442d4a9ba5c5384eb854909ffa01f5e.tar.bz2
Normalize template errors
Diffstat (limited to 'lib/template.js')
-rw-r--r--lib/template.js8
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