Skip to content

Instantly share code, notes, and snippets.

@spikebrehm
Created August 29, 2016 23:27
Show Gist options
  • Save spikebrehm/ad5a8acefcb499b73b67b27a5fd4efa7 to your computer and use it in GitHub Desktop.
Save spikebrehm/ad5a8acefcb499b73b67b27a5fd4efa7 to your computer and use it in GitHub Desktop.
React Native error bridge
#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