diff options
author | kpdecker <kpdecker@gmail.com> | 2013-10-01 20:52:14 -0500 |
---|---|---|
committer | kpdecker <kpdecker@gmail.com> | 2013-10-01 21:14:18 -0500 |
commit | 6a23391a9a72e263248f6ffa2535cfae67a2b135 (patch) | |
tree | b197bd07134aa2f38a33af4d3e6f9736892bd0e9 /lib/handlebars/exception.js | |
parent | 80b748ad3e34b29249af134e214d57fec92e22a4 (diff) | |
download | handlebars.js-6a23391a9a72e263248f6ffa2535cfae67a2b135.zip handlebars.js-6a23391a9a72e263248f6ffa2535cfae67a2b135.tar.gz handlebars.js-6a23391a9a72e263248f6ffa2535cfae67a2b135.tar.bz2 |
Break exception class out into a standalone module
Diffstat (limited to 'lib/handlebars/exception.js')
-rw-r--r-- | lib/handlebars/exception.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/handlebars/exception.js b/lib/handlebars/exception.js new file mode 100644 index 0000000..fc88534 --- /dev/null +++ b/lib/handlebars/exception.js @@ -0,0 +1,15 @@ + +var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack']; + +function Exception(message) { + var tmp = Error.prototype.constructor.apply(this, arguments); + + // 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]]; + } +} + +Exception.prototype = new Error(); + +export default Exception; |