Bug 803638 - introduce logException. r=davidb
authorEitan Isaacson <eitan@monotonous.org>
Fri, 19 Oct 2012 13:39:36 -0700
changeset 110949 b2f24b1dc78670c0aa8691c18f885663dbb51425
parent 110948 49bf10b166f9acf1722fa3fa73d21c7ae0e77d1f
child 110950 43eca3085ddc890e7791bfa6547de22cc3241495
push id93
push usernmatsakis@mozilla.com
push dateWed, 31 Oct 2012 21:26:57 +0000
reviewersdavidb
bugs803638
milestone19.0a1
Bug 803638 - introduce logException. r=davidb
accessible/src/jsat/AccessFu.jsm
accessible/src/jsat/EventManager.jsm
accessible/src/jsat/Utils.jsm
--- a/accessible/src/jsat/AccessFu.jsm
+++ b/accessible/src/jsat/AccessFu.jsm
@@ -132,17 +132,17 @@ var AccessFu = {
   _enableOrDisable: function _enableOrDisable() {
     try {
       if (this._activatePref == ACCESSFU_ENABLE ||
           this._systemPref && this._activatePref == ACCESSFU_AUTO)
         this._enable();
       else
         this._disable();
     } catch (x) {
-      Logger.error(x);
+      Logger.logException(x);
     }
   },
 
   receiveMessage: function receiveMessage(aMessage) {
     if (Logger.logLevel >= Logger.DEBUG)
       Logger.debug('Recieved', aMessage.name, JSON.stringify(aMessage.json));
 
     switch (aMessage.name) {
@@ -152,17 +152,17 @@ var AccessFu = {
                           {method: 'start', buildApp: Utils.MozBuildApp});
       break;
       case 'AccessFu:Present':
       try {
         for each (let presenter in aMessage.json) {
           Output[presenter.type](presenter.details, aMessage.target);
         }
       } catch (x) {
-        Logger.error(x);
+        Logger.logException(x);
       }
       break;
       case 'AccessFu:Input':
       Input.setEditState(aMessage.json);
       break;
     }
   },
 
@@ -336,17 +336,17 @@ var Input = {
       case 'keypress':
         this._handleKeypress(aEvent);
         break;
       case 'mozAccessFuGesture':
         this._handleGesture(aEvent);
         break;
       }
     } catch (x) {
-      Logger.error(x);
+      Logger.logException(x);
     }
   },
 
   _handleGesture: function _handleGesture(aEvent) {
     let detail = aEvent.detail;
     Logger.info('Gesture', detail.type,
                 '(fingers: ' + detail.touches.length + ')');
 
--- a/accessible/src/jsat/EventManager.jsm
+++ b/accessible/src/jsat/EventManager.jsm
@@ -37,17 +37,18 @@ var EventManager = {
       }
 
       this.present(
         function(p) {
           return p.tabStateChanged(null, 'newtab');
         }
       );
     } catch (x) {
-      Logger.error('Failed to start EventManager:', x);
+      Logger.error('Failed to start EventManager');
+      Logger.logException(x);
     }
   },
 
   stop: function stop() {
     Services.obs.removeObserver(this, 'accessible-event');
     this.presenters = [];
     this._started = false;
   },
@@ -89,29 +90,31 @@ var EventManager = {
           function(p) {
             return p.viewportChanged(window);
           }
         );
         break;
       }
       }
     } catch (x) {
-      Logger.error('Error handling DOM event:', x);
+      Logger.error('Error handling DOM event');
+      Logger.logException(x);
     }
   },
 
   observe: function observe(aSubject, aTopic, aData) {
     switch (aTopic) {
       case 'accessible-event':
         var event;
         try {
           event = aSubject.QueryInterface(Ci.nsIAccessibleEvent);
           this.handleAccEvent(event);
         } catch (x) {
-          Logger.error('Error handing accessible event:', x);
+          Logger.error('Error handing accessible event');
+          Logger.logException(x);
           return;
         }
     }
   },
 
   handleAccEvent: function handleAccEvent(aEvent) {
     if (Logger.logLevel >= Logger.DEBUG)
       Logger.debug('A11yEvent', Logger.eventToString(aEvent),
@@ -243,17 +246,17 @@ var EventManager = {
 
   present: function present(aPresenterFunc) {
     try {
       this.sendMsgFunc(
         "AccessFu:Present",
         [aPresenterFunc(p) for each (p in this.presenters)].
           filter(function(d) {return !!d;}));
     } catch (x) {
-      Logger.error(x);
+      Logger.logException(x);
     }
   },
 
   presentVirtualCursorPosition: function presentVirtualCursorPosition(aVirtualCursor) {
     let presenterContext =
       new PresenterContext(aVirtualCursor.position, null);
 
     this.present(
--- a/accessible/src/jsat/Utils.jsm
+++ b/accessible/src/jsat/Utils.jsm
@@ -93,17 +93,17 @@ var Utils = {
     return browser ? browser.contentDocument : null;
   },
 
   getMessageManager: function getMessageManager(aBrowser) {
     try {
       return aBrowser.QueryInterface(Ci.nsIFrameLoaderOwner).
          frameLoader.messageManager;
     } catch (x) {
-      Logger.error(x);
+      Logger.logException(x);
       return null;
     }
   },
 
   getAllMessageManagers: function getAllMessageManagers(aWindow) {
     let messageManagers = [];
 
     for (let i = 0; i < aWindow.messageManager.childCount; i++)
@@ -189,16 +189,26 @@ var Logger = {
       this, [this.WARNING].concat(Array.prototype.slice.call(arguments)));
   },
 
   error: function error() {
     this.log.apply(
       this, [this.ERROR].concat(Array.prototype.slice.call(arguments)));
   },
 
+  logException: function logException(aException) {
+    try {
+      this.error(
+        aException.message,
+        '(' + aException.fileName + ':' + aException.lineNumber + ')');
+    } catch (x) {
+      this.error(x);
+    }
+  },
+
   accessibleToString: function accessibleToString(aAccessible) {
     let str = '[ defunct ]';
     try {
       str = '[ ' + Utils.AccRetrieval.getStringRole(aAccessible.role) +
         ' | ' + aAccessible.name + ' ]';
     } catch (x) {
     }