Skip to content

Commit ab44d32

Browse files
sahrensFacebook Github Bot 0
authored andcommitted
Better Incremental/TaskQueue error reporting
Reviewed By: yungsters Differential Revision: D3135010 fb-gh-sync-id: 2d6d8800c7f7557221bd57869b6a6fa30d65f122 fbshipit-source-id: 2d6d8800c7f7557221bd57869b6a6fa30d65f122
1 parent c61100d commit ab44d32

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

Libraries/Experimental/Incremental.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,10 @@ class Incremental extends React.Component {
131131
}).then(() => {
132132
DEBUG && console.log('call onDone for ' + this.getName());
133133
this._mounted && this.props.onDone && this.props.onDone();
134-
});
134+
}).catch((ex) => {
135+
ex.message = `Incremental render failed for ${this.getName()}: ${ex.message}`;
136+
throw ex;
137+
}).done();
135138
}
136139

137140
render(): ?ReactElement {

Libraries/Interaction/TaskQueue.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111
*/
1212
'use strict';
1313

14-
const ErrorUtils = require('ErrorUtils');
15-
1614
const invariant = require('fbjs/lib/invariant');
1715

1816
type SimpleTask = {
@@ -96,16 +94,16 @@ class TaskQueue {
9694
} else {
9795
invariant(
9896
typeof task === 'function',
99-
'Expected Function, SimpleTask, or PromiseTask, but got: ' +
100-
JSON.stringify(task)
97+
'Expected Function, SimpleTask, or PromiseTask, but got:\n' +
98+
JSON.stringify(task, null, 2)
10199
);
102100
DEBUG && console.log('run anonymous task');
103101
task();
104102
}
105103
} catch (e) {
106-
e.message = 'TaskQueue: Error with task' + (task.name || ' ') + ': ' +
104+
e.message = 'TaskQueue: Error with task ' + (task.name || '') + ': ' +
107105
e.message;
108-
ErrorUtils.reportError(e);
106+
throw e;
109107
}
110108
}
111109
}
@@ -136,19 +134,17 @@ class TaskQueue {
136134
const stackIdx = this._queueStack.length - 1;
137135
DEBUG && console.log('push new queue: ', {stackIdx});
138136
DEBUG && console.log('exec gen task ' + task.name);
139-
ErrorUtils.applyWithGuard(task.gen)
137+
task.gen()
140138
.then(() => {
141139
DEBUG && console.log('onThen for gen task ' + task.name, {stackIdx, queueStackSize: this._queueStack.length});
142140
this._queueStack[stackIdx].popable = true;
143141
this.hasTasksToProcess() && this._onMoreTasks();
144142
})
145143
.catch((ex) => {
146-
console.warn(
147-
'TaskQueue: Error resolving Promise in task ' + task.name,
148-
ex
149-
);
144+
ex.message = `TaskQueue: Error resolving Promise in task ${task.name}: ${ex.message}`;
150145
throw ex;
151-
});
146+
})
147+
.done();
152148
}
153149
}
154150

0 commit comments

Comments
 (0)