removed DziError from codebase. It provided no functionality not inherent in the javascript built-in Error.

This commit is contained in:
thatcher 2011-12-13 18:17:46 -05:00
parent ced59b9827
commit 9642ca18e7
4 changed files with 20 additions and 63 deletions

View File

@ -32,7 +32,6 @@
<file name="src/job.js" /> <file name="src/job.js" />
<file name="src/imageloader.js" /> <file name="src/imageloader.js" />
<file name="src/tilesource.js" /> <file name="src/tilesource.js" />
<file name="src/dzierror.js" />
<file name="src/dzitilesource.js" /> <file name="src/dzitilesource.js" />
<file name="src/button.js" /> <file name="src/button.js" />
<file name="src/buttongroup.js" /> <file name="src/buttongroup.js" />

View File

@ -2583,17 +2583,6 @@ $.TileSource.prototype = {
(function( $ ){ (function( $ ){
$.DziError = function(message) {
Error.apply(this, arguments);
this.message = message;
};
$.DziError.prototype = new Error();
$.DziError.constructor = $.DziError;
}( OpenSeadragon ));
(function( $ ){
$.DziTileSource = function(width, height, tileSize, tileOverlap, tilesUrl, fileFormat, displayRects) { $.DziTileSource = function(width, height, tileSize, tileOverlap, tilesUrl, fileFormat, displayRects) {
$.TileSource.call(this, width, height, tileSize, tileOverlap, null, null); $.TileSource.call(this, width, height, tileSize, tileOverlap, null, null);
@ -2680,7 +2669,7 @@ $._DziTileSourceHelper.prototype = {
}, 1); }, 1);
return null; return null;
} }
throw new $.DziError(error); throw new Error(error);
} }
var urlParts = xmlUrl.split('/'); var urlParts = xmlUrl.split('/');
@ -2697,12 +2686,9 @@ $._DziTileSourceHelper.prototype = {
return func(obj, tilesUrl); return func(obj, tilesUrl);
} catch (e) { } catch (e) {
if (async) { if (async) {
//Start Thatcher - Throwable doesnt have getError
//error = this.getError(e).message;
return null; return null;
//End Thatcher
} else { } else {
throw this.getError(e); throw e;
} }
} }
} }
@ -2732,11 +2718,11 @@ $._DziTileSourceHelper.prototype = {
}, },
processResponse: function(xhr, tilesUrl) { processResponse: function(xhr, tilesUrl) {
if (!xhr) { if (!xhr) {
throw new $.DziError($.Strings.getString("Errors.Security")); throw new Error($.Strings.getString("Errors.Security"));
} else if (xhr.status !== 200 && xhr.status !== 0) { } else if (xhr.status !== 200 && xhr.status !== 0) {
var status = xhr.status; var status = xhr.status;
var statusText = (status == 404) ? "Not Found" : xhr.statusText; var statusText = (status == 404) ? "Not Found" : xhr.statusText;
throw new $.DziError($.Strings.getString("Errors.Status", status, statusText)); throw new Error($.Strings.getString("Errors.Status", status, statusText));
} }
var doc = null; var doc = null;
@ -2752,7 +2738,7 @@ $._DziTileSourceHelper.prototype = {
processXml: function(xmlDoc, tilesUrl) { processXml: function(xmlDoc, tilesUrl) {
if (!xmlDoc || !xmlDoc.documentElement) { if (!xmlDoc || !xmlDoc.documentElement) {
throw new $.DziError($.Strings.getString("Errors.Xml")); throw new Error($.Strings.getString("Errors.Xml"));
} }
var root = xmlDoc.documentElement; var root = xmlDoc.documentElement;
@ -2763,22 +2749,22 @@ $._DziTileSourceHelper.prototype = {
return this.processDzi(root, tilesUrl); return this.processDzi(root, tilesUrl);
} catch (e) { } catch (e) {
var defMsg = $.Strings.getString("Errors.Dzi"); var defMsg = $.Strings.getString("Errors.Dzi");
throw (e instanceof $.DziError) ? e : new $.DziError(defMsg); throw (e instanceof Error) ? e : new Error(defMsg);
} }
} else if (rootName == "Collection") { } else if (rootName == "Collection") {
throw new $.DziError($.Strings.getString("Errors.Dzc")); throw new Error($.Strings.getString("Errors.Dzc"));
} else if (rootName == "Error") { } else if (rootName == "Error") {
return this.processError(root); return this.processError(root);
} }
throw new $.DziError($.Strings.getString("Errors.Dzi")); throw new Error($.Strings.getString("Errors.Dzi"));
}, },
processDzi: function(imageNode, tilesUrl) { processDzi: function(imageNode, tilesUrl) {
var fileFormat = imageNode.getAttribute("Format"); var fileFormat = imageNode.getAttribute("Format");
if (!$.Utils.imageFormatSupported(fileFormat)) { if (!$.Utils.imageFormatSupported(fileFormat)) {
throw new $.DziError($.Strings.getString("Errors.ImageFormat", throw new Error($.Strings.getString("Errors.ImageFormat",
fileFormat.toUpperCase())); fileFormat.toUpperCase()));
} }
@ -2812,14 +2798,7 @@ $._DziTileSourceHelper.prototype = {
var messageNode = errorNode.getElementsByTagName("Message")[0]; var messageNode = errorNode.getElementsByTagName("Message")[0];
var message = messageNode.firstChild.nodeValue; var message = messageNode.firstChild.nodeValue;
throw new $.DziError(message); throw new Error(message);
},
getError: function(e) {
if (!(e instanceof DziError)) {
$.Debug.error(e.name + " while creating DZI from XML: " + e.message);
e = new $.DziError($.Strings.getString("Errors.Unknown"));
}
} }
}; };

View File

@ -1,11 +0,0 @@
(function( $ ){
$.DziError = function(message) {
Error.apply(this, arguments);
this.message = message;
};
$.DziError.prototype = new Error();
$.DziError.constructor = $.DziError;
}( OpenSeadragon ));

View File

@ -87,7 +87,7 @@ $._DziTileSourceHelper.prototype = {
}, 1); }, 1);
return null; return null;
} }
throw new $.DziError(error); throw new Error(error);
} }
var urlParts = xmlUrl.split('/'); var urlParts = xmlUrl.split('/');
@ -104,12 +104,9 @@ $._DziTileSourceHelper.prototype = {
return func(obj, tilesUrl); return func(obj, tilesUrl);
} catch (e) { } catch (e) {
if (async) { if (async) {
//Start Thatcher - Throwable doesnt have getError
//error = this.getError(e).message;
return null; return null;
//End Thatcher
} else { } else {
throw this.getError(e); throw e;
} }
} }
} }
@ -139,11 +136,11 @@ $._DziTileSourceHelper.prototype = {
}, },
processResponse: function(xhr, tilesUrl) { processResponse: function(xhr, tilesUrl) {
if (!xhr) { if (!xhr) {
throw new $.DziError($.Strings.getString("Errors.Security")); throw new Error($.Strings.getString("Errors.Security"));
} else if (xhr.status !== 200 && xhr.status !== 0) { } else if (xhr.status !== 200 && xhr.status !== 0) {
var status = xhr.status; var status = xhr.status;
var statusText = (status == 404) ? "Not Found" : xhr.statusText; var statusText = (status == 404) ? "Not Found" : xhr.statusText;
throw new $.DziError($.Strings.getString("Errors.Status", status, statusText)); throw new Error($.Strings.getString("Errors.Status", status, statusText));
} }
var doc = null; var doc = null;
@ -159,7 +156,7 @@ $._DziTileSourceHelper.prototype = {
processXml: function(xmlDoc, tilesUrl) { processXml: function(xmlDoc, tilesUrl) {
if (!xmlDoc || !xmlDoc.documentElement) { if (!xmlDoc || !xmlDoc.documentElement) {
throw new $.DziError($.Strings.getString("Errors.Xml")); throw new Error($.Strings.getString("Errors.Xml"));
} }
var root = xmlDoc.documentElement; var root = xmlDoc.documentElement;
@ -170,22 +167,22 @@ $._DziTileSourceHelper.prototype = {
return this.processDzi(root, tilesUrl); return this.processDzi(root, tilesUrl);
} catch (e) { } catch (e) {
var defMsg = $.Strings.getString("Errors.Dzi"); var defMsg = $.Strings.getString("Errors.Dzi");
throw (e instanceof $.DziError) ? e : new $.DziError(defMsg); throw (e instanceof Error) ? e : new Error(defMsg);
} }
} else if (rootName == "Collection") { } else if (rootName == "Collection") {
throw new $.DziError($.Strings.getString("Errors.Dzc")); throw new Error($.Strings.getString("Errors.Dzc"));
} else if (rootName == "Error") { } else if (rootName == "Error") {
return this.processError(root); return this.processError(root);
} }
throw new $.DziError($.Strings.getString("Errors.Dzi")); throw new Error($.Strings.getString("Errors.Dzi"));
}, },
processDzi: function(imageNode, tilesUrl) { processDzi: function(imageNode, tilesUrl) {
var fileFormat = imageNode.getAttribute("Format"); var fileFormat = imageNode.getAttribute("Format");
if (!$.Utils.imageFormatSupported(fileFormat)) { if (!$.Utils.imageFormatSupported(fileFormat)) {
throw new $.DziError($.Strings.getString("Errors.ImageFormat", throw new Error($.Strings.getString("Errors.ImageFormat",
fileFormat.toUpperCase())); fileFormat.toUpperCase()));
} }
@ -219,14 +216,7 @@ $._DziTileSourceHelper.prototype = {
var messageNode = errorNode.getElementsByTagName("Message")[0]; var messageNode = errorNode.getElementsByTagName("Message")[0];
var message = messageNode.firstChild.nodeValue; var message = messageNode.firstChild.nodeValue;
throw new $.DziError(message); throw new Error(message);
},
getError: function(e) {
if (!(e instanceof DziError)) {
$.Debug.error(e.name + " while creating DZI from XML: " + e.message);
e = new $.DziError($.Strings.getString("Errors.Unknown"));
}
} }
}; };