diff options
author | Peter Wagenet <peter.wagenet@gmail.com> | 2012-11-02 10:39:49 -0700 |
---|---|---|
committer | Peter Wagenet <peter.wagenet@gmail.com> | 2012-11-02 10:39:49 -0700 |
commit | 39832c06338c3412bae22597acfc98002d4519bf (patch) | |
tree | 8ba2c035c26a78833dea3e2a0cb3c2eeae2f7afd /lib/handlebars/utils.js | |
parent | a927a9b0adc39660f0794b9b210c9db2f7ddecd9 (diff) | |
download | handlebars.js-39832c06338c3412bae22597acfc98002d4519bf.zip handlebars.js-39832c06338c3412bae22597acfc98002d4519bf.tar.gz handlebars.js-39832c06338c3412bae22597acfc98002d4519bf.tar.bz2 |
Fix handling of Errors in Chrome
Diffstat (limited to 'lib/handlebars/utils.js')
-rw-r--r-- | lib/handlebars/utils.js | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/handlebars/utils.js b/lib/handlebars/utils.js index b53c9ef..3bc7e9b 100644 --- a/lib/handlebars/utils.js +++ b/lib/handlebars/utils.js @@ -1,14 +1,16 @@ var Handlebars = require("./base"); // BEGIN(BROWSER) + +var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + Handlebars.Exception = function(message) { var tmp = Error.prototype.constructor.apply(this, arguments); - for (var p in tmp) { - if (tmp.hasOwnProperty(p)) { this[p] = tmp[p]; } + // Unfortunately errors are not enumerable in Chrome (at least), so `for prop in tmp` doesn't work. + for (var idx = 0; idx < errorProps.length; idx++) { + this[errorProps[idx]] = tmp[errorProps[idx]]; } - - this.message = tmp.message; }; Handlebars.Exception.prototype = new Error(); |