From ab52e589d3b82ebf13c351b3ce7c5b3baf7323a4 Mon Sep 17 00:00:00 2001 From: Anup Kumar Date: Wed, 16 Dec 2015 09:43:00 +0100 Subject: [PATCH] Bug 1003204: Removed CommonUtils.exceptionStr() in services/common/ r=gfritzsche --- services/common/bagheeraclient.js | 7 ++---- services/common/hawkclient.js | 4 +--- services/common/hawkrequest.js | 2 +- .../common/modules-testing/bagheeraserver.js | 4 +--- .../common/modules-testing/storageserver.js | 10 ++++----- services/common/rest.js | 22 +++++++------------ services/common/tests/unit/head_helpers.js | 2 +- services/common/tokenserverclient.js | 7 ++---- services/common/utils.js | 3 +-- 9 files changed, 21 insertions(+), 40 deletions(-) diff --git a/services/common/bagheeraclient.js b/services/common/bagheeraclient.js index c678b4cf7b4..dd41f65dcf9 100644 --- a/services/common/bagheeraclient.js +++ b/services/common/bagheeraclient.js @@ -28,7 +28,6 @@ Cu.import("resource://gre/modules/Log.jsm"); Cu.import("resource://services-common/rest.js"); Cu.import("resource://services-common/utils.js"); - /** * Represents the result of a Bagheera request. */ @@ -185,8 +184,7 @@ BagheeraClient.prototype = Object.freeze({ let h = Services.telemetry.getHistogramById(options.telemetryCompressed); h.add(data.length); } catch (ex) { - this._log.warn("Unable to record telemetry for compressed payload size: " + - CommonUtils.exceptionStr(ex)); + this._log.warn("Unable to record telemetry for compressed payload size", ex); } } @@ -251,8 +249,7 @@ BagheeraClient.prototype = Object.freeze({ result.request = request; if (error) { - this._log.info("Transport failure on request: " + - CommonUtils.exceptionStr(error)); + this._log.info("Transport failure on request", error); result.transportSuccess = false; deferred.resolve(result); return; diff --git a/services/common/hawkclient.js b/services/common/hawkclient.js index 0b6c5eb1d24..7fad7fb99bb 100644 --- a/services/common/hawkclient.js +++ b/services/common/hawkclient.js @@ -28,7 +28,6 @@ this.EXPORTED_SYMBOLS = ["HawkClient"]; var {interfaces: Ci, utils: Cu} = Components; -Cu.import("resource://services-common/utils.js"); Cu.import("resource://services-crypto/utils.js"); Cu.import("resource://services-common/hawkrequest.js"); Cu.import("resource://services-common/observers.js"); @@ -271,8 +270,7 @@ this.HawkClient.prototype = { // gets the same one. _onComplete.call(this, error); } catch (ex) { - log.error("Unhandled exception processing response:" + - CommonUtils.exceptionStr(ex)); + log.error("Unhandled exception processing response", ex); deferred.reject(ex); } } diff --git a/services/common/hawkrequest.js b/services/common/hawkrequest.js index cb679faf228..7cd31a30661 100644 --- a/services/common/hawkrequest.js +++ b/services/common/hawkrequest.js @@ -168,7 +168,7 @@ this.Intl.prototype = { this._accepted = Services.prefs.getComplexValue( "intl.accept_languages", Ci.nsIPrefLocalizedString).data; } catch (err) { - this._log.error("Error reading intl.accept_languages pref: " + CommonUtils.exceptionStr(err)); + this._log.error("Error reading intl.accept_languages pref", err); } }, diff --git a/services/common/modules-testing/bagheeraserver.js b/services/common/modules-testing/bagheeraserver.js index 81328b40bf5..1e51b92a9f9 100644 --- a/services/common/modules-testing/bagheeraserver.js +++ b/services/common/modules-testing/bagheeraserver.js @@ -12,7 +12,6 @@ Cu.import("resource://gre/modules/Log.jsm"); Cu.import("resource://services-common/utils.js"); Cu.import("resource://testing-common/httpd.js"); - /** * This is an implementation of the Bagheera server. * @@ -159,8 +158,7 @@ BagheeraServer.prototype = { if (ex instanceof HttpError) { this._log.info("HttpError thrown: " + ex.code + " " + ex.description); } else { - this._log.warn("Exception processing request: " + - CommonUtils.exceptionStr(ex)); + this._log.warn("Exception processing request", ex); } throw ex; diff --git a/services/common/modules-testing/storageserver.js b/services/common/modules-testing/storageserver.js index 5ebc04cd325..7a529b6ea47 100644 --- a/services/common/modules-testing/storageserver.js +++ b/services/common/modules-testing/storageserver.js @@ -573,8 +573,7 @@ StorageServerCollection.prototype = { failed[record.id] = "no bso configured"; } } catch (ex) { - this._log.info("Exception when processing BSO: " + - CommonUtils.exceptionStr(ex)); + this._log.info("Exception when processing BSO", ex); failed[record.id] = "Exception when processing."; } } @@ -933,7 +932,7 @@ StorageServer.prototype = { } catch (ex) { _("=========================================="); _("Got exception starting Storage HTTP server on port " + this.port); - _("Error: " + CommonUtils.exceptionStr(ex)); + _("Error: " + Log.exceptionStr(ex)); _("Is there a process already listening on port " + this.port + "?"); _("=========================================="); do_throw(ex); @@ -1288,7 +1287,7 @@ StorageServer.prototype = { if (e instanceof HttpError) { this.respond(req, resp, e.code, e.description, "", {}, timestamp); } else { - this._log.warn(CommonUtils.exceptionStr(e)); + this._log.warn("StorageServer: handleDefault caught an error", e); throw e; } } @@ -1393,8 +1392,7 @@ StorageServer.prototype = { try { return handler.call(this, handler, req, resp, version, username, rest); } catch (ex) { - this._log.warn("Got exception during request: " + - CommonUtils.exceptionStr(ex)); + this._log.warn("Got exception during request", ex); throw ex; } } diff --git a/services/common/rest.js b/services/common/rest.js index df27318859a..50c18d9c243 100644 --- a/services/common/rest.js +++ b/services/common/rest.js @@ -361,7 +361,7 @@ RESTRequest.prototype = { channel.asyncOpen(this, null); } catch (ex) { // asyncOpen can throw in a bunch of cases -- e.g., a forbidden port. - this._log.warn("Caught an error in asyncOpen: " + CommonUtils.exceptionStr(ex)); + this._log.warn("Caught an error in asyncOpen", ex); CommonUtils.nextTick(onComplete.bind(this, ex)); } this.status = this.SENT; @@ -517,8 +517,7 @@ RESTRequest.prototype = { } } catch (ex) { this._log.warn("Exception thrown reading " + count + " bytes from " + - "the channel."); - this._log.warn(CommonUtils.exceptionStr(ex)); + "the channel", ex); throw ex; } } else { @@ -538,8 +537,7 @@ RESTRequest.prototype = { this.onProgress(); } catch (ex) { this._log.warn("Got exception calling onProgress handler, aborting " + - this.method + " " + channel.URI.spec); - this._log.debug("Exception: " + CommonUtils.exceptionStr(ex)); + this.method + " " + channel.URI.spec, ex); this.abort(); if (!this.onComplete) { @@ -606,7 +604,7 @@ RESTRequest.prototype = { } } } catch (ex) { - this._log.error("Error copying headers: " + CommonUtils.exceptionStr(ex)); + this._log.error("Error copying headers", ex); } this.channel = newChannel; @@ -642,8 +640,7 @@ RESTResponse.prototype = { try { status = this.request.channel.responseStatus; } catch (ex) { - this._log.debug("Caught exception fetching HTTP status code:" + - CommonUtils.exceptionStr(ex)); + this._log.debug("Caught exception fetching HTTP status code", ex); return null; } Object.defineProperty(this, "status", {value: status}); @@ -658,8 +655,7 @@ RESTResponse.prototype = { try { statusText = this.request.channel.responseStatusText; } catch (ex) { - this._log.debug("Caught exception fetching HTTP status text:" + - CommonUtils.exceptionStr(ex)); + this._log.debug("Caught exception fetching HTTP status text", ex); return null; } Object.defineProperty(this, "statusText", {value: statusText}); @@ -674,8 +670,7 @@ RESTResponse.prototype = { try { success = this.request.channel.requestSucceeded; } catch (ex) { - this._log.debug("Caught exception fetching HTTP success flag:" + - CommonUtils.exceptionStr(ex)); + this._log.debug("Caught exception fetching HTTP success flag", ex); return null; } Object.defineProperty(this, "success", {value: success}); @@ -694,8 +689,7 @@ RESTResponse.prototype = { headers[header.toLowerCase()] = value; }); } catch (ex) { - this._log.debug("Caught exception processing response headers:" + - CommonUtils.exceptionStr(ex)); + this._log.debug("Caught exception processing response headers", ex); return null; } diff --git a/services/common/tests/unit/head_helpers.js b/services/common/tests/unit/head_helpers.js index 41c245c7a68..b54045ec1d1 100644 --- a/services/common/tests/unit/head_helpers.js +++ b/services/common/tests/unit/head_helpers.js @@ -79,7 +79,7 @@ function httpd_setup (handlers, port=-1) { } catch (ex) { _("=========================================="); _("Got exception starting HTTP server on port " + port); - _("Error: " + CommonUtils.exceptionStr(ex)); + _("Error: " + Log.exceptionStr(ex)); _("Is there a process already listening on port " + port + "?"); _("=========================================="); do_throw(ex); diff --git a/services/common/tokenserverclient.js b/services/common/tokenserverclient.js index f7de0f78b75..42b0aef5b3b 100644 --- a/services/common/tokenserverclient.js +++ b/services/common/tokenserverclient.js @@ -16,7 +16,6 @@ var {classes: Cc, interfaces: Ci, utils: Cu, results: Cr} = Components; Cu.import("resource://gre/modules/Services.jsm"); Cu.import("resource://gre/modules/Log.jsm"); Cu.import("resource://services-common/rest.js"); -Cu.import("resource://services-common/utils.js"); Cu.import("resource://services-common/observers.js"); const PREF_LOG_LEVEL = "services.common.log.logger.tokenserverclient"; @@ -285,8 +284,7 @@ TokenServerClient.prototype = { try { cb(error, result); } catch (ex) { - self._log.warn("Exception when calling user-supplied callback: " + - CommonUtils.exceptionStr(ex)); + self._log.warn("Exception when calling user-supplied callback", ex); } cb = null; @@ -295,8 +293,7 @@ TokenServerClient.prototype = { try { client._processTokenResponse(this.response, callCallback); } catch (ex) { - this._log.warn("Error processing token server response: " + - CommonUtils.exceptionStr(ex)); + this._log.warn("Error processing token server response", ex); let error = new TokenServerClientError(ex); error.response = this.response; diff --git a/services/common/utils.js b/services/common/utils.js index 16a18a98a36..68418c5f8c4 100644 --- a/services/common/utils.js +++ b/services/common/utils.js @@ -70,7 +70,6 @@ this.CommonUtils = { }, // Import these from Log.jsm for backward compatibility - exceptionStr: Log.exceptionStr, stackTrace: Log.stackTrace, /** @@ -102,7 +101,7 @@ this.CommonUtils = { return Services.io.newURI(URIString, null, null); } catch (e) { let log = Log.repository.getLogger("Common.Utils"); - log.debug("Could not create URI: " + CommonUtils.exceptionStr(e)); + log.debug("Could not create URI", e); return null; } },