From e6e71a49531253d34e0b8ac213f7bd4077588240 Mon Sep 17 00:00:00 2001 From: Ben Alpert Date: Sat, 23 Nov 2013 00:26:10 -0500 Subject: [PATCH] ReactErrorUtils: In prod, just return the original This will save a stack frame (nice when in a debugger) and presumably be a bit faster. --- src/vendor/stubs/ReactErrorUtils.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/vendor/stubs/ReactErrorUtils.js b/src/vendor/stubs/ReactErrorUtils.js index 59c9bb4d97..05fef636c0 100644 --- a/src/vendor/stubs/ReactErrorUtils.js +++ b/src/vendor/stubs/ReactErrorUtils.js @@ -28,16 +28,18 @@ var ReactErrorUtils = { * @return {function} */ guard: function(func, name) { - return function guarded() { - try { - return func.apply(this, arguments); - } catch(ex) { - if (__DEV__) { + if (__DEV__) { + return function guarded() { + try { + return func.apply(this, arguments); + } catch(ex) { console.error(name + ': ' + ex.message); + throw ex; } - throw ex; - } - }; + }; + } else { + return func; + } } };