From b8ea7f6aba2e675b85826b0bee1f21ddd7b866a5 Mon Sep 17 00:00:00 2001 From: Igor Minar Date: Fri, 24 May 2013 11:00:14 -0700 Subject: feat(ngError): add error message compression and better error messages - add toThrowNg matcher --- src/Angular.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'src/Angular.js') diff --git a/src/Angular.js b/src/Angular.js index aefe7ad5..22fb005e 100644 --- a/src/Angular.js +++ b/src/Angular.js @@ -215,7 +215,7 @@ function nextUid() { /** * Set or clear the hashkey for an object. - * @param obj object + * @param obj object * @param h the hashkey (!truthy to delete the hashkey) */ function setHashKey(obj, h) { @@ -590,7 +590,10 @@ function isLeafNode (node) { * @returns {*} The copy or updated `destination`, if `destination` was specified. */ function copy(source, destination){ - if (isWindow(source) || isScope(source)) throw Error("Can't copy Window or Scope"); + if (isWindow(source) || isScope(source)) { + throw ngError(43, "Can't copy! Making copies of Window or Scope instances is not supported."); + } + if (!destination) { destination = source; if (source) { @@ -603,7 +606,7 @@ function copy(source, destination){ } } } else { - if (source === destination) throw Error("Can't copy equivalent objects or arrays"); + if (source === destination) throw ngError(44, "Can't copy! Source and destination are identical."); if (isArray(source)) { destination.length = 0; for ( var i = 0; i < source.length; i++) { @@ -1055,7 +1058,7 @@ function bindJQuery() { */ function assertArg(arg, name, reason) { if (!arg) { - throw new Error("Argument '" + (name || '?') + "' is " + (reason || "required")); + throw ngError(45, "Argument '{0}' is {1}", (name || '?'), (reason || "required")); } return arg; } -- cgit v1.2.3