Break exception class out into a standalone module
This commit is contained in:
+2
-1
@@ -2,7 +2,8 @@ import { HandlebarsEnvironment, createFrame, logger, log } from "./handlebars/ba
|
||||
|
||||
// Each of these augment the Handlebars object. No need to setup here.
|
||||
// (This is done to easily share code between commonjs and browse envs)
|
||||
import { SafeString, Exception, extend, escapeExpression, isEmpty } from "./handlebars/utils";
|
||||
import Exception from "./handlebars/exception";
|
||||
import { SafeString, extend, escapeExpression, isEmpty } from "./handlebars/utils";
|
||||
import { compile, precompile } from "./handlebars/compiler/compiler";
|
||||
import { template } from "./handlebars/runtime";
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
/*jshint eqnull: true */
|
||||
|
||||
import { Exception, extend, isEmpty } from "./utils";
|
||||
import { extend, isEmpty } from "./utils";
|
||||
import Exception from "./exception";
|
||||
|
||||
var K = function() { return this; };
|
||||
|
||||
@@ -19,9 +20,9 @@ var toString = Object.prototype.toString,
|
||||
|
||||
// Sourced from lodash
|
||||
// https://github.com/bestiejs/lodash/blob/master/LICENSE.txt
|
||||
function isFunction(value) {
|
||||
var isFunction = function(value) {
|
||||
return typeof value === 'function';
|
||||
}
|
||||
};
|
||||
// fallback for older versions of Chrome and Safari
|
||||
if (isFunction(/x/)) {
|
||||
isFunction = function(value) {
|
||||
@@ -31,7 +32,7 @@ if (isFunction(/x/)) {
|
||||
|
||||
function isArray(value) {
|
||||
return (value && typeof value === 'object') ? toString.call(value) === '[object Array]' : false;
|
||||
};
|
||||
}
|
||||
|
||||
export function HandlebarsEnvironment(helpers, partials) {
|
||||
this.helpers = helpers || {};
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Exception } from "../utils";
|
||||
import Exception from "../exception";
|
||||
|
||||
var exports = {};
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { Exception } from "../utils";
|
||||
import Exception from "../exception";
|
||||
import { template } from "../runtime";
|
||||
import { parse } from "./base";
|
||||
import { JavaScriptCompiler } from "./javascript-compiler";
|
||||
|
||||
@@ -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;
|
||||
@@ -1,4 +1,5 @@
|
||||
import { escapeExpression, extend, Exception } from "./utils";
|
||||
import Exception from "./exception";
|
||||
import { escapeExpression, extend } from "./utils";
|
||||
import { COMPILER_REVISION, REVISION_CHANGES } from "./base";
|
||||
|
||||
function checkRevision(compilerInfo) {
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
var toString = Object.prototype.toString,
|
||||
isArray = Array.isArray;
|
||||
|
||||
var errorProps = ['description', 'fileName', 'lineNumber', 'message', 'name', 'number', 'stack'];
|
||||
|
||||
export 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();
|
||||
|
||||
// Build out our basic SafeString type
|
||||
export function SafeString(string) {
|
||||
this.string = string;
|
||||
|
||||
Reference in New Issue
Block a user