Finish up the work to send through the error cookie

Summary: - Includes the error cookie with soft exceptions as well since they too can be updated (requires tiny Android change too)
- Passes the error cookie through instead of leaving it unused
Closes https://github.com/facebook/react-native/pull/2198

Reviewed By: @​svcscm

Differential Revision: D2455391

Pulled By: @sahrens
This commit is contained in:
James Ide 2015-09-17 18:12:46 -07:00 committed by facebook-github-bot-9
parent 1fd27dae5e
commit 4fd03ba21a
3 changed files with 27 additions and 8 deletions

View File

@ -36,7 +36,7 @@ function reportException(e: Exception, isFatal: bool, stack?: any) {
if (isFatal) {
RCTExceptionsManager.reportFatalException(e.message, stack, currentExceptionID);
} else {
RCTExceptionsManager.reportSoftException(e.message, stack);
RCTExceptionsManager.reportSoftException(e.message, stack, currentExceptionID);
}
if (__DEV__) {
(sourceMapPromise = sourceMapPromise || loadSourceMap())

View File

@ -13,10 +13,16 @@
@protocol RCTExceptionsManagerDelegate <NSObject>
// NOTE: Remove these three methods and the @optional directive after updating the codebase to use only the three below
@optional
- (void)handleSoftJSExceptionWithMessage:(NSString *)message stack:(NSArray *)stack;
- (void)handleFatalJSExceptionWithMessage:(NSString *)message stack:(NSArray *)stack;
- (void)updateJSExceptionWithMessage:(NSString *)message stack:(NSArray *)stack;
- (void)handleSoftJSExceptionWithMessage:(NSString *)message stack:(NSArray *)stack exceptionId:(NSNumber *)exceptionId;
- (void)handleFatalJSExceptionWithMessage:(NSString *)message stack:(NSArray *)stack exceptionId:(NSNumber *)exceptionId;
- (void)updateJSExceptionWithMessage:(NSString *)message stack:(NSArray *)stack exceptionId:(NSNumber *)exceptionId;
@end
@interface RCTExceptionsManager : NSObject <RCTBridgeModule>

View File

@ -39,11 +39,16 @@ RCT_EXPORT_MODULE()
}
RCT_EXPORT_METHOD(reportSoftException:(NSString *)message
stack:(NSArray *)stack)
stack:(NSArray *)stack
exceptionId:(nonnull NSNumber *)exceptionId)
{
// TODO(#7070533): report a soft error to the server
if (_delegate) {
if ([_delegate respondsToSelector:@selector(handleSoftJSExceptionWithMessage:stack:exceptionId:)]) {
[_delegate handleSoftJSExceptionWithMessage:message stack:stack exceptionId:exceptionId];
} else {
[_delegate handleSoftJSExceptionWithMessage:message stack:stack];
}
return;
}
[_bridge.redBox showErrorMessage:message withStack:stack];
@ -51,10 +56,14 @@ RCT_EXPORT_METHOD(reportSoftException:(NSString *)message
RCT_EXPORT_METHOD(reportFatalException:(NSString *)message
stack:(NSArray *)stack
exceptionId:(__unused NSNumber *)exceptionId)
exceptionId:(nonnull NSNumber *)exceptionId)
{
if (_delegate) {
if ([_delegate respondsToSelector:@selector(handleFatalJSExceptionWithMessage:stack:exceptionId:)]) {
[_delegate handleFatalJSExceptionWithMessage:message stack:stack exceptionId:exceptionId];
} else {
[_delegate handleFatalJSExceptionWithMessage:message stack:stack];
}
return;
}
@ -90,10 +99,14 @@ RCT_EXPORT_METHOD(reportFatalException:(NSString *)message
RCT_EXPORT_METHOD(updateExceptionMessage:(NSString *)message
stack:(NSArray *)stack
exceptionId:(__unused NSNumber *)exceptionId)
exceptionId:(nonnull NSNumber *)exceptionId)
{
if (_delegate) {
if ([_delegate respondsToSelector:@selector(updateJSExceptionWithMessage:stack:exceptionId:)]) {
[_delegate updateJSExceptionWithMessage:message stack:stack exceptionId:exceptionId];
} else {
[_delegate updateJSExceptionWithMessage:message stack:stack];
}
return;
}
@ -104,6 +117,6 @@ RCT_EXPORT_METHOD(updateExceptionMessage:(NSString *)message
RCT_EXPORT_METHOD(reportUnhandledException:(NSString *)message
stack:(NSArray *)stack)
{
[self reportFatalException:message stack:stack exceptionId:nil];
[self reportFatalException:message stack:stack exceptionId:@-1];
}
@end