react-native-exception-handler icon indicating copy to clipboard operation
react-native-exception-handler copied to clipboard

setNativeExceptionHandler is not working if error is not fatal

Open KESHAmambo opened this issue 5 years ago • 3 comments
trafficstars

Environment: React-Native 0.63, iOS

Steps to reproduce: I tried to produce native error within module @react-native-community/clipboard: (injected error throwing

NSLog(@"RAISING A TEST EXCEPTION");
[NSException raise:@"TEST EXCEPTION" format:@"THIS IS A TEST EXCEPTION"];

)

File: RNCClipboard.m:

RCT_EXPORT_METHOD(getString:(RCTPromiseResolveBlock)resolve
                  reject:(__unused RCTPromiseRejectBlock)reject)
{
  UIPasteboard *clipboard = [UIPasteboard generalPasteboard];
 NSLog(@"RAISING A TEST EXCEPTION");
 [NSException raise:@"TEST EXCEPTION" format:@"THIS IS A TEST EXCEPTION"];
  resolve((clipboard.string ? : @""));
}

Expected result: callback transmitted to setNativeExceptionHandler is getting called on Clipboard.getString()

Actual result: callback transmitted to setNativeExceptionHandler is not invoked on error. Instead only standard RedError screen (presented on screenshot) is shown.

Снимок экрана 2020-08-07 в 17 30 53

KESHAmambo avatar Aug 07 '20 14:08 KESHAmambo

Also I have to add that rn-test-exception-handler library for testing setNativeExceptionHandler does not work as it does not expose interface to React-Native JS code (as mentioned in its project issues)

KESHAmambo avatar Aug 07 '20 14:08 KESHAmambo

Also I have to add that rn-test-exception-handler library for testing setNativeExceptionHandler does not work as it does not expose interface to React-Native JS code (as mentioned in its project issues)

I fixed rn-test-exception-handler by manually installing the library in Xcode - don't know why autolinking didn't work

About the red screen - have you tried dismissing it? In my implementation the red-screen shows but my app still gets the exception in the handler.

NicholasIoanJones avatar Aug 18 '20 15:08 NicholasIoanJones

I have an error with this. When i get undefined object , the NativeExceptionHandler do nothing. Please help me I need it a lot.

alikhancherli avatar Sep 01 '20 11:09 alikhancherli