23
23
NSException *_RCTNotImplementedException (SEL , Class );
24
24
NSException *_RCTNotImplementedException (SEL cmd, Class cls)
25
25
{
26
- NSString *msg = [NSString stringWithFormat: @" %s is not implemented "
27
- " for the class %@ " , sel_getName (cmd), cls];
28
- return [NSException exceptionWithName: @" RCTNotDesignatedInitializerException"
29
- reason: msg userInfo: nil ];
26
+ NSString *msg = [NSString stringWithFormat:
27
+ @" %s is not implemented "
28
+ " for the class %@ " ,
29
+ sel_getName (cmd),
30
+ cls];
31
+ return [NSException exceptionWithName: @" RCTNotDesignatedInitializerException" reason: msg userInfo: nil ];
30
32
}
31
33
32
34
void RCTSetAssertFunction (RCTAssertFunction assertFunction)
@@ -43,15 +45,11 @@ void RCTAddAssertFunction(RCTAssertFunction assertFunction)
43
45
{
44
46
RCTAssertFunction existing = RCTCurrentAssertFunction;
45
47
if (existing) {
46
- RCTCurrentAssertFunction = ^(NSString *condition,
47
- NSString *fileName,
48
- NSNumber *lineNumber,
49
- NSString *function,
50
- NSString *message) {
51
-
52
- existing (condition, fileName, lineNumber, function, message);
53
- assertFunction (condition, fileName, lineNumber, function, message);
54
- };
48
+ RCTCurrentAssertFunction =
49
+ ^(NSString *condition, NSString *fileName, NSNumber *lineNumber, NSString *function, NSString *message) {
50
+ existing (condition, fileName, lineNumber, function, message);
51
+ assertFunction (condition, fileName, lineNumber, function, message);
52
+ };
55
53
} else {
56
54
RCTCurrentAssertFunction = assertFunction;
57
55
}
@@ -101,11 +99,12 @@ void RCTPerformBlockWithAssertFunction(void (^block)(void), RCTAssertFunction as
101
99
}
102
100
103
101
void _RCTAssertFormat (
104
- const char *condition,
105
- const char *fileName,
106
- int lineNumber,
107
- const char *function,
108
- NSString *format, ...)
102
+ const char *condition,
103
+ const char *fileName,
104
+ int lineNumber,
105
+ const char *function,
106
+ NSString *format,
107
+ ...)
109
108
{
110
109
RCTAssertFunction assertFunction = RCTGetLocalAssertFunction ();
111
110
if (assertFunction) {
@@ -143,9 +142,10 @@ void RCTFatal(NSError *error)
143
142
// name: RCTFatalException: <underlying error description>
144
143
// reason: <underlying error description plus JS stack trace, truncated to 175 characters>
145
144
// userInfo: <underlying error userinfo, plus untruncated description plus JS stack trace>
146
- @throw [[NSException alloc ] initWithName: name reason: message userInfo: userInfo];
145
+ @throw [[NSException alloc ] initWithName: name reason: message userInfo: userInfo];
147
146
#if DEBUG
148
- } @catch (NSException *e) {}
147
+ } @catch (NSException *e) {
148
+ }
149
149
#endif
150
150
}
151
151
}
@@ -160,34 +160,40 @@ RCTFatalHandler RCTGetFatalHandler(void)
160
160
return RCTCurrentFatalHandler;
161
161
}
162
162
163
- NSString *RCTFormatError (NSString *message, NSArray <NSDictionary <NSString *, id > *> *stackTrace, NSUInteger maxMessageLength)
163
+ NSString *
164
+ RCTFormatError (NSString *message, NSArray <NSDictionary <NSString *, id > *> *stackTrace, NSUInteger maxMessageLength)
164
165
{
165
166
if (maxMessageLength > 0 && message.length > maxMessageLength) {
166
167
message = [[message substringToIndex: maxMessageLength] stringByAppendingString: @" ..." ];
167
168
}
168
169
169
170
NSString *prettyStack = RCTFormatStackTrace (stackTrace);
170
171
171
- return [NSString stringWithFormat: @" %@%@%@ " , message, prettyStack ? @" , stack:\n " : @" " , prettyStack ? prettyStack : @" " ];
172
+ return [NSString
173
+ stringWithFormat: @" %@%@%@ " , message, prettyStack ? @" , stack:\n " : @" " , prettyStack ? prettyStack : @" " ];
172
174
}
173
175
174
- NSString *RCTFormatStackTrace (NSArray <NSDictionary <NSString *, id > *> *stackTrace) {
176
+ NSString *RCTFormatStackTrace (NSArray <NSDictionary <NSString *, id > *> *stackTrace)
177
+ {
175
178
if (stackTrace) {
176
179
NSMutableString *prettyStack = [NSMutableString string ];
177
180
178
- NSRegularExpression *regex = [NSRegularExpression regularExpressionWithPattern: @" \\ b((?:seg-\\ d+(?:_\\ d+)?|\\ d+)\\ .js)"
179
- options: NSRegularExpressionCaseInsensitive
180
- error: NULL ];
181
+ NSRegularExpression *regex =
182
+ [NSRegularExpression regularExpressionWithPattern: @" \\ b((?:seg-\\ d+(?:_\\ d+)?|\\ d+)\\ .js)"
183
+ options: NSRegularExpressionCaseInsensitive
184
+ error: NULL ];
181
185
for (NSDictionary <NSString *, id > *frame in stackTrace) {
182
186
NSString *fileName = [frame[@" file" ] lastPathComponent ];
183
- NSTextCheckingResult *match = fileName != nil ? [regex firstMatchInString: fileName options: 0 range: NSMakeRange (0 , fileName.length)] : nil ;
187
+ NSTextCheckingResult *match =
188
+ fileName != nil ? [regex firstMatchInString: fileName options: 0 range: NSMakeRange (0 , fileName.length)] : nil ;
184
189
if (match) {
185
190
fileName = [NSString stringWithFormat: @" %@ :" , [fileName substringWithRange: match.range]];
186
191
} else {
187
192
fileName = @" " ;
188
193
}
189
194
190
- [prettyStack appendFormat: @" %@ @%@%@ :%@ \n " , frame[@" methodName" ], fileName, frame[@" lineNumber" ], frame[@" column" ]];
195
+ [prettyStack
196
+ appendFormat: @" %@ @%@%@ :%@ \n " , frame[@" methodName" ], fileName, frame[@" lineNumber" ], frame[@" column" ]];
191
197
}
192
198
193
199
return prettyStack;
@@ -208,7 +214,8 @@ void RCTFatalException(NSException *exception)
208
214
#endif
209
215
@throw exception ;
210
216
#if DEBUG
211
- } @catch (NSException *e) {}
217
+ } @catch (NSException *e) {
218
+ }
212
219
#endif
213
220
}
214
221
}
0 commit comments