Throw a byte-saving AssertionError

This commit is contained in:
Tim Schaub
2017-04-13 06:37:42 -06:00
parent 4a9114cd4e
commit 6604172c1c
2 changed files with 6 additions and 1 deletions

View File

@@ -220,3 +220,7 @@ The `{-y}` placeholder requires a tile grid with extent.
### 57
At least 2 conditions are required.
### 58
Duplicate item added to a unique collection. For example, it may be that you tried to add the same layer to a map twice. Check for calls to `map.addLayer()` or other places where the map's layer collection is modified.

View File

@@ -6,6 +6,7 @@
goog.provide('ol.Collection');
goog.require('ol');
goog.require('ol.AssertionError');
goog.require('ol.CollectionEventType');
goog.require('ol.Object');
goog.require('ol.events.Event');
@@ -256,7 +257,7 @@ ol.Collection.prototype.updateLength_ = function() {
ol.Collection.prototype.assertUnique_ = function(elem, opt_except) {
for (var i = 0, ii = this.array_.length; i < ii; ++i) {
if (this.array_[i] === elem && i !== opt_except) {
throw new Error('Duplicate item added to a unique collection');
throw new ol.AssertionError(58);
}
}
};