From 9642ca18e74464d85abd6159a2642548be0d55b6 Mon Sep 17 00:00:00 2001 From: thatcher Date: Tue, 13 Dec 2011 18:17:46 -0500 Subject: [PATCH] removed DziError from codebase. It provided no functionality not inherent in the javascript built-in Error. --- build.xml | 1 - openseadragon.js | 41 ++++++++++------------------------------- src/dzierror.js | 11 ----------- src/dzitilesource.js | 30 ++++++++++-------------------- 4 files changed, 20 insertions(+), 63 deletions(-) delete mode 100644 src/dzierror.js diff --git a/build.xml b/build.xml index fc870825..143b3b5e 100644 --- a/build.xml +++ b/build.xml @@ -32,7 +32,6 @@ - diff --git a/openseadragon.js b/openseadragon.js index fabbc73a..111c8bf9 100644 --- a/openseadragon.js +++ b/openseadragon.js @@ -2583,17 +2583,6 @@ $.TileSource.prototype = { (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) { $.TileSource.call(this, width, height, tileSize, tileOverlap, null, null); @@ -2680,7 +2669,7 @@ $._DziTileSourceHelper.prototype = { }, 1); return null; } - throw new $.DziError(error); + throw new Error(error); } var urlParts = xmlUrl.split('/'); @@ -2697,12 +2686,9 @@ $._DziTileSourceHelper.prototype = { return func(obj, tilesUrl); } catch (e) { if (async) { - //Start Thatcher - Throwable doesnt have getError - //error = this.getError(e).message; return null; - //End Thatcher } else { - throw this.getError(e); + throw e; } } } @@ -2732,11 +2718,11 @@ $._DziTileSourceHelper.prototype = { }, processResponse: function(xhr, tilesUrl) { if (!xhr) { - throw new $.DziError($.Strings.getString("Errors.Security")); + throw new Error($.Strings.getString("Errors.Security")); } else if (xhr.status !== 200 && xhr.status !== 0) { var status = xhr.status; 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; @@ -2752,7 +2738,7 @@ $._DziTileSourceHelper.prototype = { processXml: function(xmlDoc, tilesUrl) { if (!xmlDoc || !xmlDoc.documentElement) { - throw new $.DziError($.Strings.getString("Errors.Xml")); + throw new Error($.Strings.getString("Errors.Xml")); } var root = xmlDoc.documentElement; @@ -2763,22 +2749,22 @@ $._DziTileSourceHelper.prototype = { return this.processDzi(root, tilesUrl); } catch (e) { 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") { - throw new $.DziError($.Strings.getString("Errors.Dzc")); + throw new Error($.Strings.getString("Errors.Dzc")); } else if (rootName == "Error") { return this.processError(root); } - throw new $.DziError($.Strings.getString("Errors.Dzi")); + throw new Error($.Strings.getString("Errors.Dzi")); }, processDzi: function(imageNode, tilesUrl) { var fileFormat = imageNode.getAttribute("Format"); if (!$.Utils.imageFormatSupported(fileFormat)) { - throw new $.DziError($.Strings.getString("Errors.ImageFormat", + throw new Error($.Strings.getString("Errors.ImageFormat", fileFormat.toUpperCase())); } @@ -2812,14 +2798,7 @@ $._DziTileSourceHelper.prototype = { var messageNode = errorNode.getElementsByTagName("Message")[0]; var message = messageNode.firstChild.nodeValue; - throw new $.DziError(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")); - } - + throw new Error(message); } }; diff --git a/src/dzierror.js b/src/dzierror.js deleted file mode 100644 index 99263469..00000000 --- a/src/dzierror.js +++ /dev/null @@ -1,11 +0,0 @@ - -(function( $ ){ - -$.DziError = function(message) { - Error.apply(this, arguments); - this.message = message; -}; -$.DziError.prototype = new Error(); -$.DziError.constructor = $.DziError; - -}( OpenSeadragon )); diff --git a/src/dzitilesource.js b/src/dzitilesource.js index bc5627e0..4ab9a084 100644 --- a/src/dzitilesource.js +++ b/src/dzitilesource.js @@ -87,7 +87,7 @@ $._DziTileSourceHelper.prototype = { }, 1); return null; } - throw new $.DziError(error); + throw new Error(error); } var urlParts = xmlUrl.split('/'); @@ -104,12 +104,9 @@ $._DziTileSourceHelper.prototype = { return func(obj, tilesUrl); } catch (e) { if (async) { - //Start Thatcher - Throwable doesnt have getError - //error = this.getError(e).message; return null; - //End Thatcher } else { - throw this.getError(e); + throw e; } } } @@ -139,11 +136,11 @@ $._DziTileSourceHelper.prototype = { }, processResponse: function(xhr, tilesUrl) { if (!xhr) { - throw new $.DziError($.Strings.getString("Errors.Security")); + throw new Error($.Strings.getString("Errors.Security")); } else if (xhr.status !== 200 && xhr.status !== 0) { var status = xhr.status; 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; @@ -159,7 +156,7 @@ $._DziTileSourceHelper.prototype = { processXml: function(xmlDoc, tilesUrl) { if (!xmlDoc || !xmlDoc.documentElement) { - throw new $.DziError($.Strings.getString("Errors.Xml")); + throw new Error($.Strings.getString("Errors.Xml")); } var root = xmlDoc.documentElement; @@ -170,22 +167,22 @@ $._DziTileSourceHelper.prototype = { return this.processDzi(root, tilesUrl); } catch (e) { 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") { - throw new $.DziError($.Strings.getString("Errors.Dzc")); + throw new Error($.Strings.getString("Errors.Dzc")); } else if (rootName == "Error") { return this.processError(root); } - throw new $.DziError($.Strings.getString("Errors.Dzi")); + throw new Error($.Strings.getString("Errors.Dzi")); }, processDzi: function(imageNode, tilesUrl) { var fileFormat = imageNode.getAttribute("Format"); if (!$.Utils.imageFormatSupported(fileFormat)) { - throw new $.DziError($.Strings.getString("Errors.ImageFormat", + throw new Error($.Strings.getString("Errors.ImageFormat", fileFormat.toUpperCase())); } @@ -219,14 +216,7 @@ $._DziTileSourceHelper.prototype = { var messageNode = errorNode.getElementsByTagName("Message")[0]; var message = messageNode.firstChild.nodeValue; - throw new $.DziError(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")); - } - + throw new Error(message); } };