Better Incremental/TaskQueue error reporting

Reviewed By: yungsters

Differential Revision: D3135010

fb-gh-sync-id: 2d6d8800c7f7557221bd57869b6a6fa30d65f122
fbshipit-source-id: 2d6d8800c7f7557221bd57869b6a6fa30d65f122
This commit is contained in:
Spencer Ahrens 2016-04-05 02:34:53 -07:00 committed by Facebook Github Bot 0
parent c61100d0ce
commit ab44d32ec5
2 changed files with 12 additions and 13 deletions

View File

@ -131,7 +131,10 @@ class Incremental extends React.Component {
}).then(() => {
DEBUG && console.log('call onDone for ' + this.getName());
this._mounted && this.props.onDone && this.props.onDone();
});
}).catch((ex) => {
ex.message = `Incremental render failed for ${this.getName()}: ${ex.message}`;
throw ex;
}).done();
}
render(): ?ReactElement {

View File

@ -11,8 +11,6 @@
*/
'use strict';
const ErrorUtils = require('ErrorUtils');
const invariant = require('fbjs/lib/invariant');
type SimpleTask = {
@ -96,16 +94,16 @@ class TaskQueue {
} else {
invariant(
typeof task === 'function',
'Expected Function, SimpleTask, or PromiseTask, but got: ' +
JSON.stringify(task)
'Expected Function, SimpleTask, or PromiseTask, but got:\n' +
JSON.stringify(task, null, 2)
);
DEBUG && console.log('run anonymous task');
task();
}
} catch (e) {
e.message = 'TaskQueue: Error with task' + (task.name || ' ') + ': ' +
e.message = 'TaskQueue: Error with task ' + (task.name || '') + ': ' +
e.message;
ErrorUtils.reportError(e);
throw e;
}
}
}
@ -136,19 +134,17 @@ class TaskQueue {
const stackIdx = this._queueStack.length - 1;
DEBUG && console.log('push new queue: ', {stackIdx});
DEBUG && console.log('exec gen task ' + task.name);
ErrorUtils.applyWithGuard(task.gen)
task.gen()
.then(() => {
DEBUG && console.log('onThen for gen task ' + task.name, {stackIdx, queueStackSize: this._queueStack.length});
this._queueStack[stackIdx].popable = true;
this.hasTasksToProcess() && this._onMoreTasks();
})
.catch((ex) => {
console.warn(
'TaskQueue: Error resolving Promise in task ' + task.name,
ex
);
ex.message = `TaskQueue: Error resolving Promise in task ${task.name}: ${ex.message}`;
throw ex;
});
})
.done();
}
}