From 629f4b3cc5b7d278b9439391be1264d3192fcda2 Mon Sep 17 00:00:00 2001 From: Dan Stillman Date: Thu, 19 Feb 2015 17:06:35 -0500 Subject: [PATCH] Make Zotero.Error instanceof Error, and give a less ugly name --- chrome/content/zotero/xpcom/error.js | 4 +++- chrome/content/zotero/xpcom/sync.js | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/chrome/content/zotero/xpcom/error.js b/chrome/content/zotero/xpcom/error.js index 51af0eadbf..00972e2821 100644 --- a/chrome/content/zotero/xpcom/error.js +++ b/chrome/content/zotero/xpcom/error.js @@ -25,7 +25,7 @@ Zotero.Error = function (message, error, data) { - this.name = "ZOTERO_ERROR"; + this.name = "Zotero Error"; this.message = message; this.data = data; if (parseInt(error) == error) { @@ -35,6 +35,8 @@ Zotero.Error = function (message, error, data) { this.error = Zotero.Error["ERROR_" + error] ? Zotero.Error["ERROR_" + error] : 0; } } +Zotero.Error.prototype = new Error; + Zotero.Error.ERROR_UNKNOWN = 0; Zotero.Error.ERROR_MISSING_OBJECT = 1; diff --git a/chrome/content/zotero/xpcom/sync.js b/chrome/content/zotero/xpcom/sync.js index 9ed9e9fca9..616d3b3737 100644 --- a/chrome/content/zotero/xpcom/sync.js +++ b/chrome/content/zotero/xpcom/sync.js @@ -2416,7 +2416,7 @@ Zotero.Sync.Server = new function () { function _error(e, extraInfo, skipReload) { - if (e.name && e.name == 'ZOTERO_ERROR') { + if (e instanceof Zotero.Error) { switch (e.error) { case Zotero.Error.ERROR_MISSING_OBJECT: case Zotero.Error.ERROR_FULL_SYNC_REQUIRED: