|
18 | 18 | */ |
19 | 19 |
|
20 | 20 |
|
21 | | -var NON_ASSIGNABLE_MODEL_EXPRESSION = 'Non-assignable model expression: '; |
22 | | - |
23 | | - |
24 | 21 | /** |
25 | 22 | * @ngdoc function |
26 | 23 | * @name ng.$compile |
@@ -155,7 +152,6 @@ function $CompileProvider($provide) { |
155 | 152 | Suffix = 'Directive', |
156 | 153 | COMMENT_DIRECTIVE_REGEXP = /^\s*directive\:\s*([\d\w\-_]+)\s+(.*)$/, |
157 | 154 | CLASS_DIRECTIVE_REGEXP = /(([\d\w\-_]+)(?:\:([^;]+))?;?)/, |
158 | | - MULTI_ROOT_TEMPLATE_ERROR = 'Template must have exactly one root element. was: ', |
159 | 155 | urlSanitizationWhitelist = /^\s*(https?|ftp|mailto|file):/; |
160 | 156 |
|
161 | 157 |
|
@@ -392,10 +388,6 @@ function $CompileProvider($provide) { |
392 | 388 | }; |
393 | 389 | } |
394 | 390 |
|
395 | | - function wrongMode(localName, mode) { |
396 | | - throw Error("Unsupported '" + mode + "' for '" + localName + "'."); |
397 | | - } |
398 | | - |
399 | 391 | function safeAddClass($element, className) { |
400 | 392 | try { |
401 | 393 | $element.addClass(className); |
@@ -669,7 +661,7 @@ function $CompileProvider($provide) { |
669 | 661 | compileNode = $template[0]; |
670 | 662 |
|
671 | 663 | if ($template.length != 1 || compileNode.nodeType !== 1) { |
672 | | - throw new Error(MULTI_ROOT_TEMPLATE_ERROR + directiveValue); |
| 664 | + throw ngError(12, "Template for directive '{0}' must have exactly one root element.", directiveName); |
673 | 665 | } |
674 | 666 |
|
675 | 667 | replaceWith(jqCollection, $compileNode, compileNode); |
@@ -755,7 +747,7 @@ function $CompileProvider($provide) { |
755 | 747 | } |
756 | 748 | value = $element[retrievalMethod]('$' + require + 'Controller'); |
757 | 749 | if (!value && !optional) { |
758 | | - throw Error("No controller: " + require); |
| 750 | + throw ngError(13, "Controller '{0}', required by directive '{1}', can't be found!", require, directiveName); |
759 | 751 | } |
760 | 752 | return value; |
761 | 753 | } else if (isArray(require)) { |
@@ -783,8 +775,8 @@ function $CompileProvider($provide) { |
783 | 775 |
|
784 | 776 | var parentScope = scope.$parent || scope; |
785 | 777 |
|
786 | | - forEach(newIsolateScopeDirective.scope, function(definiton, scopeName) { |
787 | | - var match = definiton.match(LOCAL_REGEXP) || [], |
| 778 | + forEach(newIsolateScopeDirective.scope, function(definition, scopeName) { |
| 779 | + var match = definition.match(LOCAL_REGEXP) || [], |
788 | 780 | attrName = match[3] || scopeName, |
789 | 781 | optional = (match[2] == '?'), |
790 | 782 | mode = match[1], // @, =, or & |
@@ -815,8 +807,8 @@ function $CompileProvider($provide) { |
815 | 807 | parentSet = parentGet.assign || function() { |
816 | 808 | // reset the change, or we will throw this exception on every $digest |
817 | 809 | lastValue = scope[scopeName] = parentGet(parentScope); |
818 | | - throw Error(NON_ASSIGNABLE_MODEL_EXPRESSION + attrs[attrName] + |
819 | | - ' (directive: ' + newIsolateScopeDirective.name + ')'); |
| 810 | + throw ngError(14, "Expression '{0}' used with directive '{1}' is non-assignable!", |
| 811 | + attrs[attrName], newIsolateScopeDirective.name); |
820 | 812 | }; |
821 | 813 | lastValue = scope[scopeName] = parentGet(parentScope); |
822 | 814 | scope.$watch(function parentValueWatch() { |
@@ -846,8 +838,8 @@ function $CompileProvider($provide) { |
846 | 838 | } |
847 | 839 |
|
848 | 840 | default: { |
849 | | - throw Error('Invalid isolate scope definition for directive ' + |
850 | | - newIsolateScopeDirective.name + ': ' + definiton); |
| 841 | + throw ngError(15, "Invalid isolate scope definition for directive '{0}'. Definition: {... {1}: '{2}' ...}", |
| 842 | + newIsolateScopeDirective.name, scopeName, definition); |
851 | 843 | } |
852 | 844 | } |
853 | 845 | }); |
@@ -1000,7 +992,8 @@ function $CompileProvider($provide) { |
1000 | 992 | compileNode = $template[0]; |
1001 | 993 |
|
1002 | 994 | if ($template.length != 1 || compileNode.nodeType !== 1) { |
1003 | | - throw new Error(MULTI_ROOT_TEMPLATE_ERROR + content); |
| 995 | + throw ngError(16, "Template for directive '{0}' must have exactly one root element. Template: {1}", |
| 996 | + origAsyncDirective.name, templateUrl); |
1004 | 997 | } |
1005 | 998 |
|
1006 | 999 | tempTemplateAttrs = {$attr: {}}; |
@@ -1037,7 +1030,7 @@ function $CompileProvider($provide) { |
1037 | 1030 | linkQueue = null; |
1038 | 1031 | }). |
1039 | 1032 | error(function(response, code, headers, config) { |
1040 | | - throw Error('Failed to load template: ' + config.url); |
| 1033 | + throw ngError(17, 'Failed to load template: {0}', config.url); |
1041 | 1034 | }); |
1042 | 1035 |
|
1043 | 1036 | return function delayedNodeLinkFn(ignoreChildLinkFn, scope, node, rootElement, controller) { |
@@ -1065,8 +1058,8 @@ function $CompileProvider($provide) { |
1065 | 1058 |
|
1066 | 1059 | function assertNoDuplicate(what, previousDirective, directive, element) { |
1067 | 1060 | if (previousDirective) { |
1068 | | - throw Error('Multiple directives [' + previousDirective.name + ', ' + |
1069 | | - directive.name + '] asking for ' + what + ' on: ' + startingTag(element)); |
| 1061 | + throw ngError(18, 'Multiple directives [{0}, {1}] asking for {2} on: {3}', |
| 1062 | + previousDirective.name, directive.name, what, startingTag(element)); |
1070 | 1063 | } |
1071 | 1064 | } |
1072 | 1065 |
|
|
0 commit comments