Bug 887582 - improve logException. r=yzen

This commit is contained in:
Eitan Isaacson 2013-06-27 14:15:36 -07:00
parent 38d43986be
commit feb20f50fb
4 changed files with 25 additions and 13 deletions

View File

@ -57,8 +57,7 @@ this.EventManager.prototype = {
this.present(Presentation.tabStateChanged(null, 'newtab'));
} catch (x) {
Logger.error('Failed to start EventManager');
Logger.logException(x);
Logger.logException(x, 'Failed to start EventManager');
}
},
@ -117,8 +116,7 @@ this.EventManager.prototype = {
}
}
} catch (x) {
Logger.error('Error handling DOM event');
Logger.logException(x);
Logger.logException(x, 'Error handling DOM event');
}
},
@ -421,8 +419,7 @@ const AccessibilityEventObserver = {
try {
eventManager.handleAccEvent(event);
} catch (x) {
Logger.error('Error handing accessible event');
Logger.logException(x);
Logger.logException(x, 'Error handing accessible event');
} finally {
return;
}

View File

@ -155,7 +155,7 @@ VisualPresenter.prototype = {
}
};
} catch (e) {
Logger.error('Failed to get bounds: ' + e);
Logger.logException(e, 'Failed to get bounds');
return null;
}
},

View File

@ -271,12 +271,27 @@ this.Logger = {
this, [this.ERROR].concat(Array.prototype.slice.call(arguments)));
},
logException: function logException(aException) {
logException: function logException(
aException, aErrorMessage = 'An exception has occured') {
try {
let args = [aException.message];
args.push.apply(args, aException.stack ? ['\n', aException.stack] :
['(' + aException.fileName + ':' + aException.lineNumber + ')']);
this.error.apply(this, args);
let stackMessage = '';
if (aException.stack) {
stackMessage = ' ' + aException.stack.replace(/\n/g, '\n ');
} else if (aException.location) {
let frame = aException.location;
let stackLines = [];
while (frame && frame.lineNumber) {
stackLines.push(
' ' + frame.name + '@' + frame.filename + ':' + frame.lineNumber);
frame = frame.caller;
}
stackMessage = stackLines.join('\n');
} else {
stackMessage = '(' + aException.fileName + ':' + aException.lineNumber + ')';
}
this.error(aErrorMessage + ':\n ' +
aException.message + '\n' +
stackMessage);
} catch (x) {
this.error(x);
}

View File

@ -93,7 +93,7 @@ function virtualCursorControl(aMessage) {
sendAsyncMessage('AccessFu:VirtualCursor', aMessage.json);
}
} catch (x) {
Logger.error(x);
Logger.logException(x, 'Failed to move virtual cursor');
}
}