[OpenLayers-Trac] [OpenLayers] #3320: remove Lang.js and Console.js
@requires directives
OpenLayers
trac-20090302 at openlayers.org
Thu May 26 16:25:26 EDT 2011
#3320: remove Lang.js and Console.js @requires directives
---------------------+------------------------------------------------------
Reporter: erilem | Owner:
Type: task | Status: new
Priority: major | Milestone: 2.12 Release
Component: general | Version: SVN
Keywords: | State: Needs Discussion
---------------------+------------------------------------------------------
We have a number of files that @require Lang.js and Console.js just to
output (translated) error messages when the application developer doesn't
correctly use the API.
For example !LonLat.js includes Lang.js and Console.js to display an error
message when null values are passed to the {{{add}}} method:
{{{
add:function(lon, lat) {
if ( (lon == null) || (lat == null) ) {
var msg = OpenLayers.i18n("lonlatAddError");
OpenLayers.Console.error(msg);
return null;
}
...
},
}}}
Instead of requiring Lang.js and Console.js I think we'd be better of
throwing an exception:
{{{
add:function(lon, lat) {
if ( (lon == null) || (lat == null) ) {
throw new Error('LonLat.add cannot receive null values');
}
...
},
}}}
I personally find it silly to translate error messages targeted to the
developer.
By throwing exceptions with untranslated messages we can create builds
without Console.js, and without Lang.js if no visual control is needed in
the application.
--
Ticket URL: <http://trac.openlayers.org/ticket/3320>
OpenLayers <http://openlayers.org/>
A free AJAX map viewer
More information about the Trac
mailing list