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

ReactErrorUtils: In prod, just return the original

This will save a stack frame (nice when in a debugger) and presumably be a bit faster.

Ben Alpert committed Nov 23, 2013 at 00:26 UTC e6e71a49531253d34e0b8ac213f7bd4077588240
1 file changed +10 -8
src/vendor/stubs/ReactErrorUtils.js
+10 -8
@@ -28,16 +28,18 @@ var ReactErrorUtils = {
28 * @return {function}
29 */
30 guard: function(func, name) {
31 - return function guarded() {
32 - try {
33 - return func.apply(this, arguments);
34 - } catch(ex) {
35 - if (__DEV__) {
31 + if (__DEV__) {
32 + return function guarded() {
33 + try {
34 + return func.apply(this, arguments);
35 + } catch(ex) {
36 console.error(name + ': ' + ex.message);
37 + throw ex;
38 }
38 - throw ex;
39 - }
40 - };
39 + };
40 + } else {
41 + return func;
42 + }
43 }
44 };
45