Bug 1641465 - improve AddrBookCard.jsm error reporting. r=darktrojan
authorMagnus Melin <mkmelin+mozilla@iki.fi>
Sun, 31 May 2020 20:45:34 +0300
changeset 39294 9f4a9f7ce10651f40e6788c3c1d648f4fb99d9dd
parent 39293 ad9902d060b0ab0a74854ca24ef3571ea4077470
child 39295 8f5971bfa1c6d0713b0e5a45288c595f76abe882
push id402
push userclokep@gmail.com
push dateMon, 29 Jun 2020 20:48:04 +0000
reviewersdarktrojan
bugs1641465
Bug 1641465 - improve AddrBookCard.jsm error reporting. r=darktrojan
mailnews/addrbook/jsaddrbook/AddrBookCard.jsm
--- a/mailnews/addrbook/jsaddrbook/AddrBookCard.jsm
+++ b/mailnews/addrbook/jsaddrbook/AddrBookCard.jsm
@@ -98,17 +98,17 @@ AddrBookCard.prototype = {
   get properties() {
     let entries = [...this._properties.entries()];
     let enumerator = {
       hasMoreElements() {
         return entries.length > 0;
       },
       getNext() {
         if (!this.hasMoreElements()) {
-          throw Components.Exception("", Cr.NS_ERROR_NOT_AVAILABLE);
+          throw Components.Exception("No next!", Cr.NS_ERROR_NOT_AVAILABLE);
         }
         let [name, value] = entries.shift();
         return {
           get name() {
             return name;
           },
           get value() {
             return value;
@@ -165,40 +165,46 @@ AddrBookCard.prototype = {
   getPropertyAsAString(name) {
     if (!this._properties.has(name)) {
       return "";
     }
     return this.getProperty(name);
   },
   getPropertyAsAUTF8String(name) {
     if (!this._properties.has(name)) {
-      throw Components.Exception("", Cr.NS_ERROR_NOT_AVAILABLE);
+      throw Components.Exception(`${name} N/A`, Cr.NS_ERROR_NOT_AVAILABLE);
     }
     return this.getProperty(name);
   },
   getPropertyAsUint32(name) {
     let value = this.getProperty(name);
     if (isNaN(parseInt(value, 10))) {
-      throw Components.Exception("", Cr.NS_ERROR_NOT_AVAILABLE);
+      throw Components.Exception(
+        `${name}: ${value} - not an int`,
+        Cr.NS_ERROR_NOT_AVAILABLE
+      );
     }
     return value;
   },
   getPropertyAsBool(name) {
     let value = this.getProperty(name);
     switch (value) {
       case false:
       case 0:
       case "0":
         return false;
       case true:
       case 1:
       case "1":
         return true;
     }
-    throw Components.Exception("", Cr.NS_ERROR_NOT_AVAILABLE);
+    throw Components.Exception(
+      `${name}: ${value} - not a boolean`,
+      Cr.NS_ERROR_NOT_AVAILABLE
+    );
   },
   setProperty(name, value) {
     this._properties.set(name, value);
   },
   setPropertyAsAString(name, value) {
     throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
   },
   setPropertyAsAUTF8String(name, value) {
@@ -251,14 +257,17 @@ AddrBookCard.prototype = {
     ]) {
       if (this._properties.has(name)) {
         return this._properties.get(name);
       }
     }
     return "";
   },
   copy(srcCard) {
-    throw Components.Exception("", Cr.NS_ERROR_NOT_IMPLEMENTED);
+    throw Components.Exception(
+      "nsIAbCard.copy() not implemented",
+      Cr.NS_ERROR_NOT_IMPLEMENTED
+    );
   },
   equals(card) {
     return this.UID == card.UID;
   },
 };