Created
August 29, 2016 23:27
-
-
Save spikebrehm/ad5a8acefcb499b73b67b27a5fd4efa7 to your computer and use it in GitHub Desktop.
React Native error bridge
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "ErrorBridge.h" | |
#import <React/RCTRedbox.h> | |
@implementation ErrorBridge | |
@synthesize bridge = _bridge; | |
RCT_EXPORT_MODULE() | |
- (NSArray<NSString *> *)supportedEvents | |
{ | |
return @[]; | |
} | |
RCT_EXPORT_METHOD(reportException:(NSString *)title | |
stack:(NSString *)stack | |
stackArray:(NSArray<NSDictionary *> *)stackArray | |
isFatal:(BOOL)isFatal | |
callback:(RCTResponseSenderBlock)callback) | |
{ | |
NSDictionary *userInfo = @{ | |
NSLocalizedDescriptionKey: title, | |
@"Stacktrace": stack, | |
}; | |
NSError *error = [NSError errorWithDomain:@"ReactJavaScriptError" code:0 userInfo:userInfo]; | |
< ... snip logging error to custom error logger ... > | |
[_bridge.redBox showErrorMessage:title withStack:stackArray]; | |
callback(@[]); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment