@samitouri / QOS-React-2 / commits / cb14168175

Remove unnecessary throw catch (#19044)

This was originally added so you could use "break on caught exceptions" but that feature is pretty useless these days since it's used for feature detection and Suspense. The better pattern is to use the stack trace, jump to source and set a break point here. Since DevTools injects its own console.error, we could inject a "debugger" statement in there. Conditionally. E.g. React DevTools could have a flag to toggle "break on warnings".

Sebastian Markbåge committed May 29, 2020 at 11:25 UTC cb141681750c8221ac799074df09df2bb448c7a4
1 file changed -10
packages/shared/consoleWithStackDev.js
-10
@@ -43,15 +43,5 @@ function printWarning(level, format, args) {
43 // breaks IE9: https://github.com/facebook/react/issues/13610
44 // eslint-disable-next-line react-internal/no-production-logging
45 Function.prototype.apply.call(console[level], console, argsWithFormat);
46 -
47 - try {
48 - // --- Welcome to debugging React ---
49 - // This error was thrown as a convenience so that you can use this stack
50 - // to find the callsite that caused this warning to fire.
51 - let argIndex = 0;
52 - const message =
53 - 'Warning: ' + format.replace(/%s/g, () => args[argIndex++]);
54 - throw new Error(message);
55 - } catch (x) {}
46 }
47 }