File tree Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Expand file tree Collapse file tree 2 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -58,7 +58,12 @@ function reactNativePlugin(Raven, options) {
58
58
59
59
ErrorUtils . setGlobalHandler ( function ( ) {
60
60
var error = arguments [ 0 ] ;
61
- defaultHandler . apply ( this , arguments )
61
+ // We only call the default handler in development mode so that you are
62
+ // presented with the redbox. Calling the default handler in production
63
+ // will trigger an Objective-C exception and crash the app.
64
+ if ( '__DEV__' in global && global . __DEV__ ) {
65
+ defaultHandler . apply ( this , arguments )
66
+ }
62
67
Raven . captureException ( error ) ;
63
68
} ) ;
64
69
}
Original file line number Diff line number Diff line change @@ -135,7 +135,8 @@ describe('React Native plugin', function () {
135
135
}
136
136
} ) ;
137
137
138
- it ( 'should call the default React Native handler and Raven.captureException' , function ( ) {
138
+ it ( 'should call the default React Native handler and Raven.captureException in development mode' , function ( ) {
139
+ global . __DEV__ = true ;
139
140
reactNativePlugin ( Raven ) ;
140
141
var err = new Error ( ) ;
141
142
this . sinon . stub ( Raven , 'captureException' ) ;
@@ -146,5 +147,17 @@ describe('React Native plugin', function () {
146
147
assert . isTrue ( Raven . captureException . calledOnce ) ;
147
148
assert . equal ( Raven . captureException . getCall ( 0 ) . args [ 0 ] , err ) ;
148
149
} ) ;
150
+
151
+ it ( 'should not call the default React Native handler and Raven.captureException in production mode' , function ( ) {
152
+ global . __DEV__ = false ;
153
+ reactNativePlugin ( Raven ) ;
154
+ var err = new Error ( ) ;
155
+ this . sinon . stub ( Raven , 'captureException' ) ;
156
+
157
+ this . globalErrorHandler ( err ) ;
158
+
159
+ assert . equal ( this . defaultErrorHandler . callCount , 0 ) ;
160
+ assert . equal ( Raven . captureException . callCount , 1 ) ;
161
+ } ) ;
149
162
} ) ;
150
163
} ) ;
You can’t perform that action at this time.
0 commit comments