diff options
Diffstat (limited to 'src/ng')
| -rw-r--r-- | src/ng/cacheFactory.js | 2 | ||||
| -rw-r--r-- | src/ng/compile.js | 17 | ||||
| -rw-r--r-- | src/ng/controller.js | 2 | ||||
| -rw-r--r-- | src/ng/directive/input.js | 9 | ||||
| -rw-r--r-- | src/ng/directive/ngRepeat.js | 7 | ||||
| -rw-r--r-- | src/ng/directive/select.js | 4 | ||||
| -rw-r--r-- | src/ng/httpBackend.js | 2 | ||||
| -rw-r--r-- | src/ng/interpolate.js | 2 | ||||
| -rw-r--r-- | src/ng/location.js | 7 | ||||
| -rw-r--r-- | src/ng/parse.js | 7 | ||||
| -rw-r--r-- | src/ng/rootScope.js | 5 |
11 files changed, 35 insertions, 29 deletions
diff --git a/src/ng/cacheFactory.js b/src/ng/cacheFactory.js index 1c23e063..7fcf81ff 100644 --- a/src/ng/cacheFactory.js +++ b/src/ng/cacheFactory.js @@ -28,7 +28,7 @@ function $CacheFactoryProvider() { function cacheFactory(cacheId, options) { if (cacheId in caches) { - throw ngError(10, "CacheId '{0}' is already taken!", cacheId); + throw minErr('$cacheFactory')('iid', "CacheId '{0}' is already taken!", cacheId); } var size = 0, diff --git a/src/ng/compile.js b/src/ng/compile.js index ba6e6306..faef4772 100644 --- a/src/ng/compile.js +++ b/src/ng/compile.js @@ -138,6 +138,7 @@ * {@link guide/compiler Angular HTML Compiler} section of the Developer Guide. */ +var $compileMinErr = minErr('$compile'); /** * @ngdoc service @@ -589,7 +590,7 @@ function $CompileProvider($provide) { var startNode = node; do { if (!node) { - throw ngError(51, "Unterminated attribute, found '{0}' but no matching '{1}' found.", attrStart, attrEnd); + throw $compileMinErr('utrat', "Unterminated attribute, found '{0}' but no matching '{1}' found.", attrStart, attrEnd); } if (node.nodeType == 1 /** Element **/) { if (node.hasAttribute(attrStart)) depth++; @@ -721,7 +722,7 @@ function $CompileProvider($provide) { compileNode = $template[0]; if ($template.length != 1 || compileNode.nodeType !== 1) { - throw ngError(12, "Template for directive '{0}' must have exactly one root element.", directiveName); + throw $compileMinErr('tplrt', "Template for directive '{0}' must have exactly one root element. {1}", directiveName, ''); } replaceWith(jqCollection, $compileNode, compileNode); @@ -809,7 +810,7 @@ function $CompileProvider($provide) { } value = $element[retrievalMethod]('$' + require + 'Controller'); if (!value && !optional) { - throw ngError(13, "Controller '{0}', required by directive '{1}', can't be found!", require, directiveName); + throw $compileMinErr('ctreq', "Controller '{0}', required by directive '{1}', can't be found!", require, directiveName); } return value; } else if (isArray(require)) { @@ -869,7 +870,7 @@ function $CompileProvider($provide) { parentSet = parentGet.assign || function() { // reset the change, or we will throw this exception on every $digest lastValue = scope[scopeName] = parentGet(parentScope); - throw ngError(14, "Expression '{0}' used with directive '{1}' is non-assignable!", + throw $compileMinErr('noass', "Expression '{0}' used with directive '{1}' is non-assignable!", attrs[attrName], newIsolateScopeDirective.name); }; lastValue = scope[scopeName] = parentGet(parentScope); @@ -900,7 +901,7 @@ function $CompileProvider($provide) { } default: { - throw ngError(15, "Invalid isolate scope definition for directive '{0}'. Definition: {... {1}: '{2}' ...}", + throw $compileMinErr('iscp', "Invalid isolate scope definition for directive '{0}'. Definition: {... {1}: '{2}' ...}", newIsolateScopeDirective.name, scopeName, definition); } } @@ -1057,7 +1058,7 @@ function $CompileProvider($provide) { compileNode = $template[0]; if ($template.length != 1 || compileNode.nodeType !== 1) { - throw ngError(16, "Template for directive '{0}' must have exactly one root element. Template: {1}", + throw $compileMinErr('tplrt', "Template for directive '{0}' must have exactly one root element. {1}", origAsyncDirective.name, templateUrl); } @@ -1095,7 +1096,7 @@ function $CompileProvider($provide) { linkQueue = null; }). error(function(response, code, headers, config) { - throw ngError(17, 'Failed to load template: {0}', config.url); + throw $compileMinErr('tpload', 'Failed to load template: {0}', config.url); }); return function delayedNodeLinkFn(ignoreChildLinkFn, scope, node, rootElement, controller) { @@ -1123,7 +1124,7 @@ function $CompileProvider($provide) { function assertNoDuplicate(what, previousDirective, directive, element) { if (previousDirective) { - throw ngError(18, 'Multiple directives [{0}, {1}] asking for {2} on: {3}', + throw $compileMinErr('multidir', 'Multiple directives [{0}, {1}] asking for {2} on: {3}', previousDirective.name, directive.name, what, startingTag(element)); } } diff --git a/src/ng/controller.js b/src/ng/controller.js index 2df0bde9..2078eef8 100644 --- a/src/ng/controller.js +++ b/src/ng/controller.js @@ -75,7 +75,7 @@ function $ControllerProvider() { if (identifier) { if (!(locals && typeof locals.$scope == 'object')) { - throw ngError(47, "Cannot export controller '{0}' as '{1}'! No $scope object provided via `locals`.", constructor || expression.name, identifier); + throw minErr('$controller')('noscp', "Cannot export controller '{0}' as '{1}'! No $scope object provided via `locals`.", constructor || expression.name, identifier); } locals.$scope[identifier] = instance; diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js index 591da99e..31a3ba5d 100644 --- a/src/ng/directive/input.js +++ b/src/ng/directive/input.js @@ -475,8 +475,9 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) { var patternObj = scope.$eval(pattern); if (!patternObj || !patternObj.test) { - throw ngError(5, 'ngPattern error! Expected {0} to be a RegExp but was {1}. Element: {2}', - pattern, patternObj, startingTag(element)); + throw minErr('ngPattern')('noregexp', + 'Expected {0} to be a RegExp but was {1}. Element: {2}', pattern, + patternObj, startingTag(element)); } return validate(patternObj, value); }; @@ -928,8 +929,8 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$ ngModelSet = ngModelGet.assign; if (!ngModelSet) { - throw ngError(6, "ngModel error! Expression '{0}' is non-assignable. Element: {1}", $attr.ngModel, - startingTag($element)); + throw minErr('ngModel')('noass', "Expression '{0}' is non-assignable. Element: {1}", + $attr.ngModel, startingTag($element)); } /** diff --git a/src/ng/directive/ngRepeat.js b/src/ng/directive/ngRepeat.js index 53ab4fdc..c0e2292f 100644 --- a/src/ng/directive/ngRepeat.js +++ b/src/ng/directive/ngRepeat.js @@ -191,6 +191,7 @@ */ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) { var NG_REMOVED = '$$NG_REMOVED'; + var ngRepeatMinErr = minErr('ngRepeat'); return { transclude: 'element', priority: 1000, @@ -204,7 +205,7 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) { hashFnLocals = {$id: hashKey}; if (!match) { - throw ngError(7, "ngRepeat error! Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.", + throw ngRepeatMinErr('iexp', "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.", expression); } @@ -229,7 +230,7 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) { match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/); if (!match) { - throw ngError(8, "ngRepeat error! '_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.", + throw ngRepeatMinErr('iidexp', "'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.", lhs); } valueIdentifier = match[3] || match[1]; @@ -291,7 +292,7 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) { if (block && block.startNode) lastBlockMap[block.id] = block; }); // This is a duplicate and we need to throw an error - throw ngError(50, "ngRepeat error! Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: {0}, Duplicate key: {1}", + throw ngRepeatMinErr('dupes', "Duplicates in a repeater are not allowed. Use 'track by' expression to specify unique keys. Repeater: {0}, Duplicate key: {1}", expression, trackById); } else { // new never before seen block diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js index b7a4f58b..0d5221fb 100644 --- a/src/ng/directive/select.js +++ b/src/ng/directive/select.js @@ -300,8 +300,8 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) { var match; if (! (match = optionsExp.match(NG_OPTIONS_REGEXP))) { - throw ngError(9, - "ngOptions error! Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '{0}'. Element: {1}", + throw minErr('ngOptions')('iexp', + "Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '{0}'. Element: {1}", optionsExp, startingTag(selectElement)); } diff --git a/src/ng/httpBackend.js b/src/ng/httpBackend.js index 5b965705..69711df2 100644 --- a/src/ng/httpBackend.js +++ b/src/ng/httpBackend.js @@ -2,7 +2,7 @@ var XHR = window.XMLHttpRequest || function() { try { return new ActiveXObject("Msxml2.XMLHTTP.6.0"); } catch (e1) {} try { return new ActiveXObject("Msxml2.XMLHTTP.3.0"); } catch (e2) {} try { return new ActiveXObject("Msxml2.XMLHTTP"); } catch (e3) {} - throw ngError(19, "This browser does not support XMLHttpRequest."); + throw minErr('$httpBackend')('noxhr', "This browser does not support XMLHttpRequest."); }; diff --git a/src/ng/interpolate.js b/src/ng/interpolate.js index 42218fd3..51f4630d 100644 --- a/src/ng/interpolate.js +++ b/src/ng/interpolate.js @@ -139,7 +139,7 @@ function $InterpolateProvider() { return concat.join(''); } catch(err) { - var newErr = ngError(48, "$interpolate error! Can't interpolate: {0}\n{1}", text, err.toString()); + var newErr = minErr('$interpolate')('interr', "Can't interpolate: {0}\n{1}", text, err.toString()); $exceptionHandler(newErr); } }; diff --git a/src/ng/location.js b/src/ng/location.js index 7b011abe..de629d42 100644 --- a/src/ng/location.js +++ b/src/ng/location.js @@ -3,6 +3,7 @@ var SERVER_MATCH = /^([^:]+):\/\/(\w+:{0,1}\w*@)?(\{?[\w\.-]*\}?)(:([0-9]+))?(\/[^\?#]*)?(\?([^#]*))?(#(.*))?$/, PATH_MATCH = /^([^\?#]*)(\?([^#]*))?(#(.*))?$/, DEFAULT_PORTS = {'http': 80, 'https': 443, 'ftp': 21}; +var $locationMinErr = minErr('$location'); /** @@ -95,7 +96,7 @@ function LocationHtml5Url(appBase, basePrefix) { matchUrl(url, parsed); var pathUrl = beginsWith(appBaseNoFile, url); if (!isString(pathUrl)) { - throw ngError(21, '$location error! Invalid url "{0}", missing path prefix "{1}".', url, appBaseNoFile); + throw $locationMinErr('nopp', 'Invalid url "{0}", missing path prefix "{1}".', url, appBaseNoFile); } matchAppUrl(pathUrl, parsed); extend(this, parsed); @@ -157,11 +158,11 @@ function LocationHashbangUrl(appBase, hashPrefix) { matchUrl(url, this); var withoutBaseUrl = beginsWith(appBase, url) || beginsWith(appBaseNoFile, url); if (!isString(withoutBaseUrl)) { - throw ngError(22, '$location error! Invalid url "{0}", does not start with "{1}".', url, appBase); + throw $locationMinErr('istart', 'Invalid url "{0}", does not start with "{1}".', url, appBase); } var withoutHashUrl = withoutBaseUrl.charAt(0) == '#' ? beginsWith(hashPrefix, withoutBaseUrl) : withoutBaseUrl; if (!isString(withoutHashUrl)) { - throw ngError(49, '$location error! Invalid url "{0}", missing hash prefix "{1}".', url, hashPrefix); + throw $locationMinErr('nohash', 'Invalid url "{0}", missing hash prefix "{1}".', url, hashPrefix); } matchAppUrl(withoutHashUrl, this); this.$$compose(); diff --git a/src/ng/parse.js b/src/ng/parse.js index 5af52f60..8bb4b5e9 100644 --- a/src/ng/parse.js +++ b/src/ng/parse.js @@ -36,6 +36,7 @@ var OPERATORS = { '!':function(self, locals, a){return !a(self, locals);} }; var ESCAPE = {"n":"\n", "f":"\f", "r":"\r", "t":"\t", "v":"\v", "'":"'", '"':'"'}; +var $parseMinErr = minErr('$parse'); function lex(text, csp){ var tokens = [], @@ -126,7 +127,7 @@ function lex(text, csp){ var colStr = (isDefined(start) ? "s " + start + "-" + index + " [" + text.substring(start, end) + "]" : " " + end); - throw ngError(23, "Lexer Error: {0} at column{1} in expression [{2}].", + throw $parseMinErr('lexerr', "Lexer Error: {0} at column{1} in expression [{2}].", error, colStr, text); } @@ -309,14 +310,14 @@ function parser(text, json, $filter, csp){ /////////////////////////////////// function throwError(msg, token) { - throw ngError(24, + throw $parseMinErr('syntax', "Syntax Error: Token '{0}' {1} at column {2} of the expression [{3}] starting at [{4}].", token.text, msg, (token.index + 1), text, text.substring(token.index)); } function peekToken() { if (tokens.length === 0) - throw ngError(25, "Unexpected end of expression: {0}", text); + throw $parseMinErr('ueoe', "Unexpected end of expression: {0}", text); return tokens[0]; } diff --git a/src/ng/rootScope.js b/src/ng/rootScope.js index 66486551..4db38804 100644 --- a/src/ng/rootScope.js +++ b/src/ng/rootScope.js @@ -60,6 +60,7 @@ */ function $RootScopeProvider(){ var TTL = 10; + var $rootScopeMinErr = minErr('$rootScope'); this.digestTtl = function(value) { if (arguments.length) { @@ -556,7 +557,7 @@ function $RootScopeProvider(){ if(dirty && !(ttl--)) { clearPhase(); - throw ngError(27, + throw $rootScopeMinErr('infdig', '{0} $digest() iterations reached. Aborting!\nWatchers fired in the last 5 iterations: {1}', TTL, toJson(watchLog)); } @@ -920,7 +921,7 @@ function $RootScopeProvider(){ function beginPhase(phase) { if ($rootScope.$$phase) { - throw ngError(28, '{0} already in progress', $rootScope.$$phase); + throw $rootScopeMinErr('inprog', '{0} already in progress', $rootScope.$$phase); } $rootScope.$$phase = phase; |
