mirror of
https://github.com/openseadragon/openseadragon.git
synced 2024-11-22 21:26:10 +03:00
Graceful handling of cross-domain tilesource failures on IE<10
The TileSource error handling path used to raise non-obvious "Unspecified error" exceptions on IE < 10 when configured with a URL from a different origin (hostname or port) because the handler included ``xhr.status`` in the error message, triggering a security exception. Now the second exception is caught and the log message will use the original exception message instead to make the root cause more obvious.
This commit is contained in:
parent
1b6cf93474
commit
baa3559df1
@ -320,9 +320,29 @@ $.TileSource.prototype = {
|
|||||||
$.makeAjaxRequest( url, function( xhr ) {
|
$.makeAjaxRequest( url, function( xhr ) {
|
||||||
var data = processResponse( xhr );
|
var data = processResponse( xhr );
|
||||||
callback( data );
|
callback( data );
|
||||||
}, function ( xhr ) {
|
}, function ( xhr, exc ) {
|
||||||
|
var msg;
|
||||||
|
|
||||||
|
/*
|
||||||
|
IE < 10 will block XHR requests to different origins. Any property access on the request
|
||||||
|
object will raise an exception which we'll attempt to handle by formatting the original
|
||||||
|
exception rather than the second one raised when we try to access xhr.status
|
||||||
|
*/
|
||||||
|
try {
|
||||||
|
msg = "HTTP " + xhr.status + " attempting to load TileSource";
|
||||||
|
} catch ( e ) {
|
||||||
|
var formattedExc;
|
||||||
|
if ( typeof( exc ) == "undefined" || !exc.toString ) {
|
||||||
|
formattedExc = "Unknown error";
|
||||||
|
} else {
|
||||||
|
formattedExc = exc.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
msg = formattedExc + " attempting to load TileSource";
|
||||||
|
}
|
||||||
|
|
||||||
_this.raiseEvent( 'open-failed', {
|
_this.raiseEvent( 'open-failed', {
|
||||||
message: "HTTP " + xhr.status + " attempting to load TileSource",
|
message: msg,
|
||||||
source: url
|
source: url
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user