Bug 658740: Test Pilot error logger throws exception. r=dtownsend a=gavin DONTBUILD

This commit is contained in:
Jono S Xia 2011-05-23 15:41:35 -07:00
Родитель 291c3f01be
Коммит b3085cf596
2 изменённых файлов: 20 добавлений и 15 удалений

Просмотреть файл

@ -512,15 +512,15 @@ exports.RemoteExperimentLoader.prototype = {
remoteExperiments[filename] = this._loader.require(filename);
this._logger.info("Loaded " + filename + " OK.");
} catch(e) {
/* Turn the load-time errors into strings and store them, so we can display
* them on a debug page or include them with a data upload! (Don't store
* exception objects directly as that causes garbage collector problems-
* aka bug 646122) */
let errStr = e.name + " on line " + e.lineNumber + " of file " +
e.fileName + ": " + e.message;
/* Turn the load-time errors into strings and store them, so we can display
* them on a debug page or include them with a data upload! (Don't store
* exception objects directly as that causes garbage collector problems-
* aka bug 646122) */
let errStr = e.name + " on line " + e.lineNumber + " of file " +
e.fileName + ": " + e.message;
this._loadErrors.push(errStr);
this._logger.warn("Error loading " + filename);
this._logger.warn(e);
this._logger.warn(errStr);
}
}
return remoteExperiments;

Просмотреть файл

@ -597,7 +597,7 @@ TestPilotExperiment.prototype = {
}
}
} catch(e) {
this._logger.warn("Error in getStudyMetadata: " + e);
this._dataStore.logException("getStudyMetadata: " + e);
}
return null;
},
@ -660,6 +660,7 @@ TestPilotExperiment.prototype = {
// This method handles all date-related status changes and should be
// called periodically.
let currentDate = this._now();
let self = this;
// Reset automatically recurring tests:
if (this._recursAutomatically &&
@ -703,7 +704,6 @@ TestPilotExperiment.prototype = {
currentDate <= this._endDate) {
this._logger.info("Study now starting.");
// clear the data before starting.
let self = this;
this._dataStore.wipeAllData(function() {
// Experiment is now in progress.
self.changeStatus(TaskConstants.STATUS_IN_PROGRESS, true);
@ -714,7 +714,6 @@ TestPilotExperiment.prototype = {
// What happens when a test finishes:
if (this._status < TaskConstants.STATUS_FINISHED &&
currentDate > this._endDate) {
let self = this;
let setDataDeletionDate = true;
this._logger.info("Passed End Date - Switched Task Status to Finished");
this.changeStatus(TaskConstants.STATUS_FINISHED);
@ -896,7 +895,6 @@ TestPilotExperiment.prototype = {
optOut: function TestPilotExperiment_optOut(reason, callback) {
// Regardless of study ID, post the opt-out message to a special
// database table of just opt-out messages; include study ID in metadata.
let url = Application.prefs.getValue(DATA_UPLOAD_PREF, "") + "opt-out";
let logger = this._logger;
this.onExperimentShutdown();
@ -909,6 +907,7 @@ TestPilotExperiment.prototype = {
if (reason) {
// Send us the reason...
// (TODO: include metadata?)
let url = Application.prefs.getValue(DATA_UPLOAD_PREF, "") + "opt-out";
let answer = {id: this._id,
reason: reason};
let dataString = JSON.stringify(answer);
@ -924,17 +923,23 @@ TestPilotExperiment.prototype = {
if (req.readyState == 4) {
if (req.status == 200 || req.status == 201 || req.status == 202) {
logger.info("Quit reason posted successfully " + req.responseText);
callback(true);
if (callback) {
callback(true);
}
} else {
logger.warn(req.status + " posting error " + req.responseText);
callback(false);
if (callback) {
callback(false);
}
}
}
};
logger.trace("Sending quit reason.");
req.send(dataString);
} else {
callback(false);
if (callback) {
callback(false);
}
}
},
@ -1211,4 +1216,4 @@ TestPilotLegacyStudy.prototype = {
// TODO test that they don't say "thanks for contributing" if the
// user didn't actually complete them...
};
TestPilotLegacyStudy.prototype.__proto__ = TestPilotTask;
TestPilotLegacyStudy.prototype.__proto__ = TestPilotTask;