aboutsummaryrefslogtreecommitdiffstats
path: root/src/ng/directive
diff options
context:
space:
mode:
Diffstat (limited to 'src/ng/directive')
-rw-r--r--src/ng/directive/input.js7
-rw-r--r--src/ng/directive/ngRepeat.js12
-rw-r--r--src/ng/directive/select.js8
3 files changed, 14 insertions, 13 deletions
diff --git a/src/ng/directive/input.js b/src/ng/directive/input.js
index 543ed367..610396a5 100644
--- a/src/ng/directive/input.js
+++ b/src/ng/directive/input.js
@@ -475,7 +475,8 @@ function textInputType(scope, element, attr, ctrl, $sniffer, $browser) {
var patternObj = scope.$eval(pattern);
if (!patternObj || !patternObj.test) {
- throw new Error('Expected ' + pattern + ' to be a RegExp but was ' + patternObj);
+ throw ngError(5, 'ngPattern error! Expected {0} to be a RegExp but was {1}. Element: {2}',
+ pattern, patternObj, startingTag(element));
}
return validate(patternObj, value);
};
@@ -918,8 +919,8 @@ var NgModelController = ['$scope', '$exceptionHandler', '$attrs', '$element', '$
ngModelSet = ngModelGet.assign;
if (!ngModelSet) {
- throw Error(NON_ASSIGNABLE_MODEL_EXPRESSION + $attr.ngModel +
- ' (' + startingTag($element) + ')');
+ throw ngError(6, "ngModel error! 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 330f6abb..34d32f59 100644
--- a/src/ng/directive/ngRepeat.js
+++ b/src/ng/directive/ngRepeat.js
@@ -157,8 +157,8 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
hashFnLocals = {$id: hashKey};
if (!match) {
- throw Error("Expected ngRepeat in form of '_item_ in _collection_[ track by _id_]' but got '" +
- expression + "'.");
+ throw ngError(7, "ngRepeat error! Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.",
+ expression);
}
lhs = match[1];
@@ -182,8 +182,8 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);
if (!match) {
- throw Error("'item' in 'item in collection' should be identifier or (key, value) but got '" +
- lhs + "'.");
+ throw ngError(8, "ngRepeat error! '_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.",
+ lhs);
}
valueIdentifier = match[3] || match[1];
keyIdentifier = match[2];
@@ -244,8 +244,8 @@ var ngRepeatDirective = ['$parse', '$animator', function($parse, $animator) {
if (block && block.element) lastBlockMap[block.id] = block;
});
// This is a duplicate and we need to throw an error
- throw new Error('Duplicates in a repeater are not allowed. Repeater: ' + expression +
- ' key: ' + trackById);
+ 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}",
+ expression, trackById);
} else {
// new never before seen block
nextBlockOrder[index] = { id: trackById };
diff --git a/src/ng/directive/select.js b/src/ng/directive/select.js
index 7a1cab53..6dda33f5 100644
--- a/src/ng/directive/select.js
+++ b/src/ng/directive/select.js
@@ -300,9 +300,9 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
var match;
if (! (match = optionsExp.match(NG_OPTIONS_REGEXP))) {
- throw Error(
- "Expected ngOptions in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_ (track by _expr_)?'" +
- " but got '" + optionsExp + "'.");
+ throw ngError(9,
+ "ngOptions error! Expected expression in form of '_select_ (as _label_)? for (_key_,)?_value_ in _collection_' but got '{0}'. Element: {1}",
+ optionsExp, startingTag(selectElement));
}
var displayFn = $parse(match[2] || match[1]),
@@ -357,7 +357,7 @@ var selectDirective = ['$compile', '$parse', function($compile, $parse) {
for (var trackIndex = 0; trackIndex < collection.length; trackIndex++) {
locals[valueName] = collection[trackIndex];
if (trackFn(scope, locals) == key) break;
- }
+ }
} else {
locals[valueName] = collection[key];
}