Use ol.error instead of throwing directly.

This commit is contained in:
Marc Jansen
2012-06-22 12:36:44 +02:00
parent 2d50a35850
commit f143f32a6f
2 changed files with 9 additions and 5 deletions

View File

@@ -3,6 +3,7 @@ goog.provide('ol.geom.Collection');
goog.require('goog.array');
goog.require('ol.geom.Geometry');
goog.require('ol.Projection');
goog.require('ol.base');
/**
* Creates ol.geom.Collection objects.
@@ -96,8 +97,9 @@ ol.geom.Collection.prototype.setComponents = function(components) {
if (allValidTypes) {
this.components_ = components;
} else {
throw new Error('ol.geom.Collection: at least one component passed to '
+ 'setComponents is not allowed.');
var msg = 'ol.geom.Collection: at least one component passed to '
+ 'setComponents is not allowed.';
ol.error(msg);
}
};
@@ -111,8 +113,8 @@ ol.geom.Collection.prototype.addComponent = function(component, index) {
if (this.isAllowedComponent(component)) {
goog.array.insertAt(this.components_, component, index);
} else {
throw new Error("ol.geom.Collection: The component is not allowed "
+ "to be added.");
var msg = 'ol.geom.Collection: component is not allowed to be added.';
ol.error(msg);
}
};

View File

@@ -4,6 +4,7 @@ goog.require('ol.geom.Geometry');
goog.require('ol.Projection');
goog.require('ol.coord.AccessorInterface');
goog.require('ol.base');
/**
* Creates ol.geom.Point objects.
@@ -135,7 +136,8 @@ ol.geom.Point.prototype._transform = function(proj) {
var point = {'x': this.x_, 'y': this.y_};
var sourceProj = this.projection_;
if (!goog.isDefAndNotNull(sourceProj)) {
throw new Error("Cannot transform a point without a source projection.");
var msg = 'Cannot transform a point without a source projection.';
ol.error(msg);
}
ol.Projection.transform(point, sourceProj, proj);