react-native-navigation的迁移库

RNNErrorHandler.m 944B

1234567891011121314151617181920212223
  1. #import "RNNErrorHandler.h"
  2. static NSString* const domain = @"com.reactnativenavigation";
  3. @implementation RNNErrorHandler
  4. + (void)reject:(RCTPromiseRejectBlock)reject withErrorCode:(NSInteger)errorCode errorDescription:(NSString*)errorDescription {
  5. NSError *error = [NSError errorWithDomain:domain code:errorCode userInfo:@{NSLocalizedFailureReasonErrorKey: errorDescription}];
  6. if (reject) {
  7. reject([NSString stringWithFormat:@"%ld", (long)errorCode], errorDescription, error);
  8. }
  9. }
  10. + (NSString *)getCallerFunctionName {
  11. NSString *sourceString = [[NSThread callStackSymbols] objectAtIndex:2];
  12. NSCharacterSet *separatorSet = [NSCharacterSet characterSetWithCharactersInString:@" -[]+?.,"];
  13. NSMutableArray *array = [NSMutableArray arrayWithArray:[sourceString componentsSeparatedByCharactersInSet:separatorSet]];
  14. [array removeObject:@""];
  15. return [[[array objectAtIndex:4] componentsSeparatedByString:@":"] objectAtIndex:0];
  16. }
  17. @end