2015-02-20 04:10:52 +00:00
|
|
|
// Copyright 2004-present Facebook. All Rights Reserved.
|
|
|
|
|
|
|
|
#import "RCTExceptionsManager.h"
|
|
|
|
|
|
|
|
#import "RCTRedBox.h"
|
|
|
|
|
|
|
|
@implementation RCTExceptionsManager
|
2015-03-11 20:53:30 +00:00
|
|
|
{
|
|
|
|
__weak id<RCTExceptionsManagerDelegate> _delegate;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)initWithDelegate:(id<RCTExceptionsManagerDelegate>)delegate
|
|
|
|
{
|
|
|
|
if ((self = [super init])) {
|
|
|
|
_delegate = delegate;
|
|
|
|
}
|
|
|
|
return self;
|
|
|
|
}
|
|
|
|
|
|
|
|
- (instancetype)init
|
|
|
|
{
|
|
|
|
return [self initWithDelegate:nil];
|
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
|
|
|
|
- (void)reportUnhandledExceptionWithMessage:(NSString *)message stack:(NSArray *)stack
|
|
|
|
{
|
|
|
|
RCT_EXPORT(reportUnhandledException);
|
|
|
|
|
2015-03-11 20:53:30 +00:00
|
|
|
if (_delegate) {
|
|
|
|
[_delegate unhandledJSExceptionWithMessage:message stack:stack];
|
|
|
|
} else {
|
|
|
|
[[RCTRedBox sharedInstance] showErrorMessage:message withStack:stack];
|
|
|
|
}
|
2015-02-20 04:10:52 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
- (void)updateExceptionMessage:(NSString *)message stack:(NSArray *)stack
|
|
|
|
{
|
|
|
|
RCT_EXPORT(updateExceptionMessage);
|
|
|
|
|
|
|
|
[[RCTRedBox sharedInstance] updateErrorMessage:message withStack:stack];
|
|
|
|
}
|
|
|
|
|
|
|
|
@end
|