|
11 | 11 | */
|
12 | 12 | 'use strict';
|
13 | 13 |
|
14 |
| -const ErrorUtils = require('ErrorUtils'); |
15 |
| - |
16 | 14 | const invariant = require('fbjs/lib/invariant');
|
17 | 15 |
|
18 | 16 | type SimpleTask = {
|
@@ -96,16 +94,16 @@ class TaskQueue {
|
96 | 94 | } else {
|
97 | 95 | invariant(
|
98 | 96 | 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) |
101 | 99 | );
|
102 | 100 | DEBUG && console.log('run anonymous task');
|
103 | 101 | task();
|
104 | 102 | }
|
105 | 103 | } catch (e) {
|
106 |
| - e.message = 'TaskQueue: Error with task' + (task.name || ' ') + ': ' + |
| 104 | + e.message = 'TaskQueue: Error with task ' + (task.name || '') + ': ' + |
107 | 105 | e.message;
|
108 |
| - ErrorUtils.reportError(e); |
| 106 | + throw e; |
109 | 107 | }
|
110 | 108 | }
|
111 | 109 | }
|
@@ -136,19 +134,17 @@ class TaskQueue {
|
136 | 134 | const stackIdx = this._queueStack.length - 1;
|
137 | 135 | DEBUG && console.log('push new queue: ', {stackIdx});
|
138 | 136 | DEBUG && console.log('exec gen task ' + task.name);
|
139 |
| - ErrorUtils.applyWithGuard(task.gen) |
| 137 | + task.gen() |
140 | 138 | .then(() => {
|
141 | 139 | DEBUG && console.log('onThen for gen task ' + task.name, {stackIdx, queueStackSize: this._queueStack.length});
|
142 | 140 | this._queueStack[stackIdx].popable = true;
|
143 | 141 | this.hasTasksToProcess() && this._onMoreTasks();
|
144 | 142 | })
|
145 | 143 | .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}`; |
150 | 145 | throw ex;
|
151 |
| - }); |
| 146 | + }) |
| 147 | + .done(); |
152 | 148 | }
|
153 | 149 | }
|
154 | 150 |
|
|
0 commit comments