Skip to content

Commit dbd05ac

Browse files
peteroida7ul
authored andcommitted
rename constants to prevent duplicate symbols (#16)
1 parent 6cb12e0 commit dbd05ac

File tree

1 file changed

+37
-37
lines changed

1 file changed

+37
-37
lines changed

ios/ReactNativeExceptionHandler.m

Lines changed: 37 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33

44
// CONSTANTS
5-
NSString * const UncaughtExceptionHandlerSignalExceptionName = @"UncaughtExceptionHandlerSignalExceptionName";
6-
NSString * const UncaughtExceptionHandlerSignalKey = @"UncaughtExceptionHandlerSignalKey";
7-
NSString * const UncaughtExceptionHandlerAddressesKey = @"UncaughtExceptionHandlerAddressesKey";
8-
volatile int32_t UncaughtExceptionCount = 0;
9-
const int32_t UncaughtExceptionMaximum = 10;
10-
const NSInteger UncaughtExceptionHandlerSkipAddressCount = 4;
11-
const NSInteger UncaughtExceptionHandlerReportAddressCount = 5;
5+
NSString * const RNUncaughtExceptionHandlerSignalExceptionName = @"RNUncaughtExceptionHandlerSignalExceptionName";
6+
NSString * const RNUncaughtExceptionHandlerSignalKey = @"RNUncaughtExceptionHandlerSignalKey";
7+
NSString * const RNUncaughtExceptionHandlerAddressesKey = @"RNUncaughtExceptionHandlerAddressesKey";
8+
volatile int32_t RNUncaughtExceptionCount = 0;
9+
const int32_t RNUncaughtExceptionMaximum = 10;
10+
const NSInteger RNUncaughtExceptionHandlerSkipAddressCount = 4;
11+
const NSInteger RNUncaughtExceptionHandlerReportAddressCount = 5;
1212

1313

1414
@implementation ReactNativeExceptionHandler
@@ -34,18 +34,18 @@ - (dispatch_queue_t)methodQueue
3434
//variable that holds the default native error handler
3535
void (^defaultNativeErrorCallbackBlock)(NSException *exception, NSString *readeableException) =
3636
^(NSException *exception, NSString *readeableException){
37-
37+
3838
UIAlertController* alert = [UIAlertController
3939
alertControllerWithTitle:@"Unexpected error occured"
4040
message:[NSString stringWithFormat:@"%@\n%@",
4141
@"Appologies..The app will close now \nPlease restart the app\n",
4242
readeableException]
4343
preferredStyle:UIAlertControllerStyleAlert];
44-
44+
4545
UIApplication* app = [UIApplication sharedApplication];
4646
UIViewController * rootViewController = app.delegate.window.rootViewController;
4747
[rootViewController presentViewController:alert animated:YES completion:nil];
48-
48+
4949
[NSTimer scheduledTimerWithTimeInterval:5.0
5050
target:[ReactNativeExceptionHandler class]
5151
selector:@selector(releaseExceptionHold)
@@ -66,7 +66,7 @@ - (dispatch_queue_t)methodQueue
6666
jsErrorCallbackBlock = ^(NSException *exception, NSString *readeableException){
6767
callback(@[readeableException]);
6868
};
69-
69+
7070
NSSetUncaughtExceptionHandler(&HandleException);
7171
signal(SIGABRT, SignalHandler);
7272
signal(SIGILL, SignalHandler);
@@ -102,16 +102,16 @@ - (void)handleException:(NSException *)exception
102102
{
103103
NSString * readeableError = [NSString stringWithFormat:NSLocalizedString(@"%@\n%@", nil),
104104
[exception reason],
105-
[[exception userInfo] objectForKey:UncaughtExceptionHandlerAddressesKey]];
105+
[[exception userInfo] objectForKey:RNUncaughtExceptionHandlerAddressesKey]];
106106
dismissApp = false;
107-
107+
108108
if(nativeErrorCallbackBlock != nil){
109109
nativeErrorCallbackBlock(exception,readeableError);
110110
}else{
111111
defaultNativeErrorCallbackBlock(exception,readeableError);
112112
}
113113
jsErrorCallbackBlock(exception,readeableError);
114-
114+
115115
CFRunLoopRef runLoop = CFRunLoopGetCurrent();
116116
CFArrayRef allModes = CFRunLoopCopyAllModes(runLoop);
117117
while (!dismissApp)
@@ -126,18 +126,18 @@ - (void)handleException:(NSException *)exception
126126
i++;
127127
}
128128
}
129-
129+
130130
CFRelease(allModes);
131-
131+
132132
NSSetUncaughtExceptionHandler(NULL);
133133
signal(SIGABRT, SIG_DFL);
134134
signal(SIGILL, SIG_DFL);
135135
signal(SIGSEGV, SIG_DFL);
136136
signal(SIGFPE, SIG_DFL);
137137
signal(SIGBUS, SIG_DFL);
138138
signal(SIGPIPE, SIG_DFL);
139-
140-
kill(getpid(), [[[exception userInfo] objectForKey:UncaughtExceptionHandlerSignalKey] intValue]);
139+
140+
kill(getpid(), [[[exception userInfo] objectForKey:RNUncaughtExceptionHandlerSignalKey] intValue]);
141141

142142
}
143143

@@ -148,19 +148,19 @@ - (void)handleException:(NSException *)exception
148148

149149
void HandleException(NSException *exception)
150150
{
151-
int32_t exceptionCount = OSAtomicIncrement32(&UncaughtExceptionCount);
152-
if (exceptionCount > UncaughtExceptionMaximum)
151+
int32_t exceptionCount = OSAtomicIncrement32(&RNUncaughtExceptionCount);
152+
if (exceptionCount > RNUncaughtExceptionMaximum)
153153
{
154154
return;
155155
}
156-
156+
157157
NSArray *callStack = [ReactNativeExceptionHandler backtrace];
158158
NSMutableDictionary *userInfo =
159159
[NSMutableDictionary dictionaryWithDictionary:[exception userInfo]];
160160
[userInfo
161161
setObject:callStack
162-
forKey:UncaughtExceptionHandlerAddressesKey];
163-
162+
forKey:RNUncaughtExceptionHandlerAddressesKey];
163+
164164
[[[ReactNativeExceptionHandler alloc] init]
165165
performSelectorOnMainThread:@selector(handleException:)
166166
withObject:
@@ -173,35 +173,35 @@ void HandleException(NSException *exception)
173173

174174
void SignalHandler(int signal)
175175
{
176-
int32_t exceptionCount = OSAtomicIncrement32(&UncaughtExceptionCount);
177-
if (exceptionCount > UncaughtExceptionMaximum)
176+
int32_t exceptionCount = OSAtomicIncrement32(&RNUncaughtExceptionCount);
177+
if (exceptionCount > RNUncaughtExceptionMaximum)
178178
{
179179
return;
180180
}
181-
181+
182182
NSMutableDictionary *userInfo =
183183
[NSMutableDictionary
184184
dictionaryWithObject:[NSNumber numberWithInt:signal]
185-
forKey:UncaughtExceptionHandlerSignalKey];
186-
185+
forKey:RNUncaughtExceptionHandlerSignalKey];
186+
187187
NSArray *callStack = [ReactNativeExceptionHandler backtrace];
188188
[userInfo
189189
setObject:callStack
190-
forKey:UncaughtExceptionHandlerAddressesKey];
191-
190+
forKey:RNUncaughtExceptionHandlerAddressesKey];
191+
192192
[[[ReactNativeExceptionHandler alloc] init]
193193
performSelectorOnMainThread:@selector(handleException:)
194194
withObject:
195195
[NSException
196-
exceptionWithName:UncaughtExceptionHandlerSignalExceptionName
196+
exceptionWithName:RNUncaughtExceptionHandlerSignalExceptionName
197197
reason:
198198
[NSString stringWithFormat:
199199
NSLocalizedString(@"Signal %d was raised.", nil),
200200
signal]
201201
userInfo:
202202
[NSDictionary
203203
dictionaryWithObject:[NSNumber numberWithInt:signal]
204-
forKey:UncaughtExceptionHandlerSignalKey]]
204+
forKey:RNUncaughtExceptionHandlerSignalKey]]
205205
waitUntilDone:YES];
206206
}
207207

@@ -215,19 +215,19 @@ + (NSArray *)backtrace
215215
void* callstack[128];
216216
int frames = backtrace(callstack, 128);
217217
char **strs = backtrace_symbols(callstack, frames);
218-
218+
219219
int i;
220220
NSMutableArray *backtrace = [NSMutableArray arrayWithCapacity:frames];
221221
for (
222-
i = UncaughtExceptionHandlerSkipAddressCount;
223-
i < UncaughtExceptionHandlerSkipAddressCount +
224-
UncaughtExceptionHandlerReportAddressCount;
222+
i = RNUncaughtExceptionHandlerSkipAddressCount;
223+
i < RNUncaughtExceptionHandlerSkipAddressCount +
224+
RNUncaughtExceptionHandlerReportAddressCount;
225225
i++)
226226
{
227227
[backtrace addObject:[NSString stringWithUTF8String:strs[i]]];
228228
}
229229
free(strs);
230-
230+
231231
return backtrace;
232232
}
233233

0 commit comments

Comments
 (0)