Skip to content
This repository was archived by the owner on Oct 2, 2019. It is now read-only.

Commit 08f3ec5

Browse files
committed
Fix exceptions
1 parent 97624a1 commit 08f3ec5

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/select.js

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,16 @@ angular.module('ui.select', [])
2222
placeholder: '' // Empty by default, like HTML tag <select>
2323
})
2424

25+
// See Rename minErr and make it accessible from outside https://github.com/angular/angular.js/issues/6913
26+
.service('uiSelectMinErr', function() {
27+
var minErr = angular.$$minErr('ui.select');
28+
return function() {
29+
var error = minErr.apply(this, arguments);
30+
var message = error.message.replace(new RegExp('\nhttp://errors.angularjs.org/.*'), '');
31+
return new Error(message);
32+
}
33+
})
34+
2535
/**
2636
* Parses "repeat" attribute.
2737
*
@@ -31,7 +41,7 @@ angular.module('ui.select', [])
3141
* Original discussion about parsing "repeat" attribute instead of fully relying on ng-repeat:
3242
* https://github.com/angular-ui/ui-select/commit/5dd63ad#commitcomment-5504697
3343
*/
34-
.service('RepeatParser', function() {
44+
.service('RepeatParser', ['uiSelectMinErr', function(uiSelectMinErr) {
3545
var self = this;
3646

3747
/**
@@ -47,8 +57,8 @@ angular.module('ui.select', [])
4757
var match = expression.match(/^\s*([\s\S]+?)\s+in\s+([\s\S]+?)(?:\s+track\s+by\s+([\s\S]+?))?\s*$/);
4858

4959
if (!match) {
50-
throw new Error("Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.",
51-
expression);
60+
throw uiSelectMinErr('iexp', "Expected expression in form of '_item_ in _collection_[ track by _id_]' but got '{0}'.",
61+
expression);
5262
}
5363

5464
var lhs = match[1]; // Left-hand side
@@ -57,8 +67,8 @@ angular.module('ui.select', [])
5767

5868
match = lhs.match(/^(?:([\$\w]+)|\(([\$\w]+)\s*,\s*([\$\w]+)\))$/);
5969
if (!match) {
60-
throw new Error("'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.",
61-
lhs);
70+
throw uiSelectMinErr('iidexp', "'_item_' in '_item_ in _collection_' should be an identifier or '(_key_, _value_)' expression, but got '{0}'.",
71+
lhs);
6272
}
6373

6474
var valueIdentifier = match[3] || match[1];
@@ -78,7 +88,7 @@ angular.module('ui.select', [])
7888
}
7989
return expression;
8090
};
81-
})
91+
}])
8292

8393
/**
8494
* Contains ui-select "intelligence".

0 commit comments

Comments
 (0)