Skip to content

Commit e4ae222

Browse files
committed
Catches and logs errors so they don't get swallowed by the Promise chain.
1 parent 08d1dfe commit e4ae222

File tree

4 files changed

+13
-1
lines changed

4 files changed

+13
-1
lines changed

commonjs/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,5 +160,9 @@ function reactTreeWalker(element, visitor, context) {
160160
return element.props && element.props.children ? element.props.children : undefined;
161161
}, visitor(element, null, context), context, true);
162162
}
163+
}).catch(function (err) {
164+
// We don't want errors to be swallowed!
165+
console.error('Error walking your react tree');
166+
console.error(err);
163167
});
164168
}

src/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,9 @@ export default function reactTreeWalker(element, visitor, context) {
152152
true,
153153
)
154154
}
155+
}).catch((err) => {
156+
// We don't want errors to be swallowed!
157+
console.error('Error walking your react tree')
158+
console.error(err)
155159
})
156160
}

umd/react-tree-walker.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,10 @@ function reactTreeWalker(element, visitor, context) {
249249
return element.props && element.props.children ? element.props.children : undefined;
250250
}, visitor(element, null, context), context, true);
251251
}
252+
}).catch(function (err) {
253+
// We don't want errors to be swallowed!
254+
console.error('Error walking your react tree');
255+
console.error(err);
252256
});
253257
}
254258

umd/react-tree-walker.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)