Merge pull request #6707 from tschaub/errors-url

Set version when building ol package
This commit is contained in:
Tim Schaub
2017-04-13 20:24:36 -06:00
committed by GitHub
5 changed files with 20 additions and 4 deletions

View File

@@ -13,11 +13,12 @@ goog.require('ol');
*/
ol.AssertionError = function(code) {
var path = ol.VERSION ? ol.VERSION.split('-')[0] : 'latest';
/**
* @type {string}
*/
this.message = 'Assertion failed. See ' +
(ol.VERSION ? 'https://openlayers.org/en/' + ol.VERSION.split('-')[0] : '') +
this.message = 'Assertion failed. See https://openlayers.org/en/' + path +
'/doc/errors/#' + code + ' for details.';
/**

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);
}
}
};