Changing prototype.js ajax stuff so exceptions aren't swallowed by default. If you want this behavior, set request.options.onException to something that swallows, or use OpenLayers.Ajax.Responders.register for onException. r=crschmidt (closes #1232)
git-svn-id: http://svn.openlayers.org/trunk/openlayers@5567 dc9f47b5-9b13-0410-9fdd-eb0c1a62fdaf
This commit is contained in:
@@ -493,14 +493,49 @@ OpenLayers.Ajax.Request = OpenLayers.Class(OpenLayers.Ajax.Base, {
|
||||
|
||||
/**
|
||||
* Method: dispatchException
|
||||
* If the optional onException function is set, execute it
|
||||
* and then dispatch the call to any other listener registered
|
||||
* for onException.
|
||||
*
|
||||
* If no optional onException function is set, we suspect that
|
||||
* the user may have also not used
|
||||
* OpenLayers.Ajax.Responders.register to register a listener
|
||||
* for the onException call. To make sure that something
|
||||
* gets done with this exception, only dispatch the call if there
|
||||
* are listeners.
|
||||
*
|
||||
* If you explicitly want to swallow exceptions, set
|
||||
* request.options.onException to an empty function (function(){})
|
||||
* or register an empty function with <OpenLayers.Ajax.Responders>
|
||||
* for onException.
|
||||
*
|
||||
* Parameters:
|
||||
* exception - {?}
|
||||
*/
|
||||
dispatchException: function(exception) {
|
||||
(this.options.onException ||
|
||||
OpenLayers.Ajax.emptyFunction)(this, exception);
|
||||
OpenLayers.Ajax.Responders.dispatch('onException', this, exception);
|
||||
var handler = this.options.onException;
|
||||
if(handler) {
|
||||
// call options.onException and alert any other listeners
|
||||
handler(this, exception);
|
||||
OpenLayers.Ajax.Responders.dispatch('onException', this, exception);
|
||||
} else {
|
||||
// check if there are any other listeners
|
||||
var listener = false;
|
||||
var responders = OpenLayers.Ajax.Responders.responders;
|
||||
for (var i = 0; i < responders.length; i++) {
|
||||
if(responders[i].onException) {
|
||||
listener = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(listener) {
|
||||
// call all listeners
|
||||
OpenLayers.Ajax.Responders.dispatch('onException', this, exception);
|
||||
} else {
|
||||
// let the exception through
|
||||
throw exception;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user