Bug 1003204: Removed CommonUtils.exceptionStr() in toolkit/ r=gfritzsche
authorAnup Kumar <allamsetty.anup@gmail.com>
Fri, 18 Dec 2015 04:05:00 +0100
changeset 314080 ec660a46136a6df47ebbcf9274ac35738c550331
parent 314079 e8acf773c3d6ae9e5ad8d587d2ce7c65f9e1e645
child 314081 9433893449d376f76d22faed6cdffe20ee3ab4ac
push id5703
push userraliiev@mozilla.com
push dateMon, 07 Mar 2016 14:18:41 +0000
treeherdermozilla-beta@31e373ad5b5f [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgfritzsche
bugs1003204
milestone46.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1003204: Removed CommonUtils.exceptionStr() in toolkit/ r=gfritzsche
toolkit/components/crashes/CrashManager.jsm
toolkit/modules/ProfileAge.jsm
toolkit/modules/SessionRecorder.jsm
toolkit/modules/Sqlite.jsm
--- a/toolkit/components/crashes/CrashManager.jsm
+++ b/toolkit/components/crashes/CrashManager.jsm
@@ -9,17 +9,16 @@ const myScope = this;
 
 Cu.import("resource://gre/modules/Log.jsm", this);
 Cu.import("resource://gre/modules/osfile.jsm", this);
 Cu.import("resource://gre/modules/Promise.jsm", this);
 Cu.import("resource://gre/modules/Services.jsm", this);
 Cu.import("resource://gre/modules/Task.jsm", this);
 Cu.import("resource://gre/modules/Timer.jsm", this);
 Cu.import("resource://gre/modules/XPCOMUtils.jsm", this);
-Cu.import("resource://services-common/utils.js", this);
 Cu.import("resource://gre/modules/TelemetryController.jsm");
 Cu.import("resource://gre/modules/KeyValueParser.jsm");
 
 this.EXPORTED_SYMBOLS = [
   "CrashManager",
 ];
 
 /**
@@ -267,43 +266,41 @@ this.CrashManager.prototype = Object.fre
                 break;
 
               default:
                 Cu.reportError("Unhandled crash event file return code. Please " +
                                "file a bug: " + result);
             }
           } catch (ex) {
             if (ex instanceof OS.File.Error) {
-              this._log.warn("I/O error reading " + entry.path + ": " +
-                             CommonUtils.exceptionStr(ex));
+              this._log.warn("I/O error reading " + entry.path, ex);
             } else {
               // We should never encounter an exception. This likely represents
               // a coding error because all errors should be detected and
               // converted to return codes.
               //
               // If we get here, report the error and delete the source file
               // so we don't see it again.
               Cu.reportError("Exception when processing crash event file: " +
-                             CommonUtils.exceptionStr(ex));
+                             Log.exceptionStr(ex));
               deletePaths.push(entry.path);
             }
           }
         }
 
         if (needsSave) {
           let store = yield this._getStore();
           yield store.save();
         }
 
         for (let path of deletePaths) {
           try {
             yield OS.File.remove(path);
           } catch (ex) {
-            this._log.warn("Error removing event file (" + path + "): " +
-                           CommonUtils.exceptionStr(ex));
+            this._log.warn("Error removing event file (" + path + ")", ex);
           }
         }
 
         return unprocessedFiles.length;
 
       } finally {
         this._aggregatePromise = false;
         this._storeProtectedCount--;
--- a/toolkit/modules/ProfileAge.jsm
+++ b/toolkit/modules/ProfileAge.jsm
@@ -151,17 +151,17 @@ this.ProfileAge.prototype = {
           if (timestamp < oldest) {
             oldest = timestamp;
           }
         }
       }
 
       function onStatFailure(e) {
         // Never mind.
-        self._log.debug("Stat failure: " + CommonUtils.exceptionStr(e));
+        self._log.debug("Stat failure", e);
       }
 
       return OS.File.stat(entry.path)
                     .then(onStatSuccess, onStatFailure);
     }
 
     let promise = iterator.forEach(onEntry);
 
--- a/toolkit/modules/SessionRecorder.jsm
+++ b/toolkit/modules/SessionRecorder.jsm
@@ -10,17 +10,16 @@ this.EXPORTED_SYMBOLS = [
 
 const {classes: Cc, interfaces: Ci, utils: Cu} = Components;
 
 Cu.import("resource://gre/modules/Preferences.jsm");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Log.jsm");
 Cu.import("resource://services-common/utils.js");
 
-
 // We automatically prune sessions older than this.
 const MAX_SESSION_AGE_MS = 7 * 24 * 60 * 60 * 1000; // 7 days.
 const STARTUP_RETRY_INTERVAL_MS = 5000;
 
 // Wait up to 5 minutes for startup measurements before giving up.
 const MAX_STARTUP_TRIES = 300000 / STARTUP_RETRY_INTERVAL_MS;
 
 /**
@@ -339,18 +338,17 @@ SessionRecorder.prototype = Object.freez
         m: this.main,
         fp: this.firstPaint,
         sr: this.sessionRestored,
       };
 
       this._log.debug("Recording last sessions as #" + count + ".");
       this._prefs.set("previous." + count, JSON.stringify(obj));
     } catch (ex) {
-      this._log.warn("Exception when migrating last session: " +
-                     CommonUtils.exceptionStr(ex));
+      this._log.warn("Exception when migrating last session", ex);
     } finally {
       this._log.debug("Resetting prefs from last session.");
       for (let pref of this._CURRENT_PREFS) {
         this._prefs.reset(pref);
       }
     }
   },
 
--- a/toolkit/modules/Sqlite.jsm
+++ b/toolkit/modules/Sqlite.jsm
@@ -19,18 +19,16 @@ Cu.import("resource://gre/modules/Timer.
 XPCOMUtils.defineLazyModuleGetter(this, "AsyncShutdown",
                                   "resource://gre/modules/AsyncShutdown.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Services",
                                   "resource://gre/modules/Services.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "OS",
                                   "resource://gre/modules/osfile.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Log",
                                   "resource://gre/modules/Log.jsm");
-XPCOMUtils.defineLazyModuleGetter(this, "CommonUtils",
-                                  "resource://services-common/utils.js");
 XPCOMUtils.defineLazyModuleGetter(this, "FileUtils",
                                   "resource://gre/modules/FileUtils.jsm");
 XPCOMUtils.defineLazyModuleGetter(this, "Task",
                                   "resource://gre/modules/Task.jsm");
 XPCOMUtils.defineLazyServiceGetter(this, "FinalizationWitnessService",
                                    "@mozilla.org/toolkit/finalizationwitness;1",
                                    "nsIFinalizationWitnessService");
 XPCOMUtils.defineLazyModuleGetter(this, "PromiseUtils",
@@ -575,47 +573,42 @@ ConnectionData.prototype = Object.freeze
             yield this.execute("BEGIN " + type + " TRANSACTION");
           } catch (ex) {
             // Unfortunately, if we are wrapping an existing connection, a
             // transaction could have been started by a client of the same
             // connection that doesn't use Sqlite.jsm (e.g. C++ consumer).
             // The best we can do is proceed without a transaction and hope
             // things won't break.
             if (wrappedConnections.has(this._identifier)) {
-              this._log.warn("A new transaction could not be started cause the wrapped connection had one in progress: " +
-                             CommonUtils.exceptionStr(ex));
+              this._log.warn("A new transaction could not be started cause the wrapped connection had one in progress", ex);
               // Unmark the in progress transaction, since it's managed by
               // some other non-Sqlite.jsm client.  See the comment above.
               this._hasInProgressTransaction = false;
             } else {
-              this._log.warn("A transaction was already in progress, likely a nested transaction: " +
-                             CommonUtils.exceptionStr(ex));
+              this._log.warn("A transaction was already in progress, likely a nested transaction", ex);
               throw ex;
             }
           }
 
           let result;
           try {
             result = yield Task.spawn(func);
           } catch (ex) {
             // It's possible that the exception has been caused by trying to
             // close the connection in the middle of a transaction.
             if (this._closeRequested) {
-              this._log.warn("Connection closed while performing a transaction: " +
-                             CommonUtils.exceptionStr(ex));
+              this._log.warn("Connection closed while performing a transaction", ex);
             } else {
-              this._log.warn("Error during transaction. Rolling back: " +
-                             CommonUtils.exceptionStr(ex));
+              this._log.warn("Error during transaction. Rolling back", ex);
               // If we began a transaction, we must rollback it.
               if (this._hasInProgressTransaction) {
                 try {
                   yield this.execute("ROLLBACK TRANSACTION");
                 } catch (inner) {
-                  this._log.warn("Could not roll back transaction: " +
-                                 CommonUtils.exceptionStr(inner));
+                  this._log.warn("Could not roll back transaction", inner);
                 }
               }
             }
             // Rethrow the exception.
             throw ex;
           }
 
           // See comment above about connection being closed during transaction.
@@ -624,18 +617,17 @@ ConnectionData.prototype = Object.freeze
             throw new Error("Connection closed before committing the transaction.");
           }
 
           // If we began a transaction, we must commit it.
           if (this._hasInProgressTransaction) {
             try {
               yield this.execute("COMMIT TRANSACTION");
             } catch (ex) {
-              this._log.warn("Error committing transaction: " +
-                             CommonUtils.exceptionStr(ex));
+              this._log.warn("Error committing transaction", ex);
               throw ex;
             }
           }
 
           return result;
         } finally {
           this._hasInProgressTransaction = false;
         }
@@ -771,18 +763,17 @@ ConnectionData.prototype = Object.freeze
             onRow(row);
           } catch (e) {
             if (e instanceof StopIteration) {
               userCancelled = true;
               pending.cancel();
               break;
             }
 
-            self._log.warn("Exception when calling onRow callback: " +
-                           CommonUtils.exceptionStr(e));
+            self._log.warn("Exception when calling onRow callback", e);
           }
         }
       },
 
       handleError: function (error) {
         self._log.info("Error when executing SQL (" +
                        error.result + "): " + error.message);
         errors.push(error);
@@ -937,17 +928,17 @@ function openConnection(options) {
         return;
       }
       log.info("Connection opened");
       try {
         resolve(
           new OpenedConnection(connection.QueryInterface(Ci.mozIStorageAsyncConnection),
                               identifier, openedOptions));
       } catch (ex) {
-        log.warn("Could not open database: " + CommonUtils.exceptionStr(ex));
+        log.warn("Could not open database", ex);
         reject(ex);
       }
     });
   });
 }
 
 /**
  * Creates a clone of an existing and open Storage connection.  The clone has
@@ -1015,17 +1006,17 @@ function cloneStorageConnection(options)
         log.warn("Could not clone connection: " + status);
         reject(new Error("Could not clone connection: " + status));
       }
       log.info("Connection cloned");
       try {
         let conn = connection.QueryInterface(Ci.mozIStorageAsyncConnection);
         resolve(new OpenedConnection(conn, identifier, openedOptions));
       } catch (ex) {
-        log.warn("Could not clone database: " + CommonUtils.exceptionStr(ex));
+        log.warn("Could not clone database", ex);
         reject(ex);
       }
     });
   });
 }
 
 /**
  * Wraps an existing and open Storage connection with Sqlite.jsm API.  The
@@ -1065,17 +1056,17 @@ function wrapStorageConnection(options) 
     try {
       let conn = connection.QueryInterface(Ci.mozIStorageAsyncConnection);
       let wrapper = new OpenedConnection(conn, identifier);
       // We must not handle shutdown of a wrapped connection, since that is
       // already handled by the opener.
       wrappedConnections.add(identifier);
       resolve(wrapper);
     } catch (ex) {
-      log.warn("Could not wrap database: " + CommonUtils.exceptionStr(ex));
+      log.warn("Could not wrap database", ex);
       throw ex;
     }
   });
 }
 
 /**
  * Handle on an opened SQLite database.
  *