Skip to content

Instantly share code, notes, and snippets.

@njif
Created October 3, 2014 06:52
Show Gist options
  • Select an option

  • Save njif/20a8b422594e08e630bc to your computer and use it in GitHub Desktop.

Select an option

Save njif/20a8b422594e08e630bc to your computer and use it in GitHub Desktop.
exception.js
// handlebars/exception.js
var __module5__ = (function() {
"use strict";
var __exports__;
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
function Exception(message, node) {
var line;
if (node && node.firstLine) {
line = node.firstLine;
message += ' - ' + line + ':' + node.firstColumn;
}
var tmp = Error.prototype.constructor.call(this, message);
// 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]];
}
if (line) {
this.lineNumber = line;
this.column = node.firstColumn;
}
}
Exception.prototype = new Error();
__exports__ = Exception;
return __exports__;
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment