From ab44d32ec5ed92d1ba3a1b85c526d424a7453699 Mon Sep 17 00:00:00 2001 From: Spencer Ahrens Date: Tue, 5 Apr 2016 02:34:53 -0700 Subject: [PATCH] Better Incremental/TaskQueue error reporting Reviewed By: yungsters Differential Revision: D3135010 fb-gh-sync-id: 2d6d8800c7f7557221bd57869b6a6fa30d65f122 fbshipit-source-id: 2d6d8800c7f7557221bd57869b6a6fa30d65f122 --- Libraries/Experimental/Incremental.js | 5 ++++- Libraries/Interaction/TaskQueue.js | 20 ++++++++------------ 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/Libraries/Experimental/Incremental.js b/Libraries/Experimental/Incremental.js index 7170c1312..ea47b323f 100644 --- a/Libraries/Experimental/Incremental.js +++ b/Libraries/Experimental/Incremental.js @@ -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 { diff --git a/Libraries/Interaction/TaskQueue.js b/Libraries/Interaction/TaskQueue.js index 211540b16..3b6b15839 100644 --- a/Libraries/Interaction/TaskQueue.js +++ b/Libraries/Interaction/TaskQueue.js @@ -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(); } }