jhomlala / catcher

Flutter error catching & handling plugin. Handles and reports exceptions in your app!
Apache License 2.0
787 stars 177 forks source link

[BUG] StackTrace in Sentry is incorrect when using reportCheckedError #213

Open shenjingfs opened 2 years ago

shenjingfs commented 2 years ago

Using Catcher.reportCheckedError to report a catched error, like this:

try {
  // Do some thing
} catch (error, stackTrace) {
  Catcher.reportCheckedError(error, stackTrace);
}

The console log:

I/flutter (15609): [2022-03-17 18:46:53.281839 | Catcher | INFO] ============================== CATCHER LOG ==============================
I/flutter (15609): [2022-03-17 18:46:53.282378 | Catcher | INFO] Crash occurred on 2022-03-17 18:46:53.281426
...
...
I/flutter (15609): [2022-03-17 18:46:53.287439 | Catcher | INFO] ---------- ERROR ----------
I/flutter (15609): [2022-03-17 18:46:53.287509 | Catcher | INFO] IAPError(code: purchase_error, source: google_play, message: BillingResponse.error, details: )
I/flutter (15609): [2022-03-17 18:46:53.287562 | Catcher | INFO] 
I/flutter (15609): [2022-03-17 18:46:53.287738 | Catcher | INFO] ------- STACK TRACE -------
I/flutter (15609): [2022-03-17 18:46:53.287947 | Catcher | INFO] #0      InAppPurchaseController.onError (package:XXXX/in_app_purchase_controller.dart:210:71)
I/flutter (15609): [2022-03-17 18:46:53.287994 | Catcher | INFO] #1      InAppPurchaseController._onIapCallback (package:XXXX/in_app_purchase_controller.dart:149:11)
I/flutter (15609): [2022-03-17 18:46:53.288033 | Catcher | INFO] #2      _rootRunUnary (dart:async/zone.dart:1436:47)
I/flutter (15609): [2022-03-17 18:46:53.288069 | Catcher | INFO] #3      _CustomZone.runUnary (dart:async/zone.dart:1335:19)
I/flutter (15609): [2022-03-17 18:46:53.288106 | Catcher | INFO] #4      _CustomZone.runUnaryGuarded (dart:async/zone.dart:1244:7)
I/flutter (15609): [2022-03-17 18:46:53.288144 | Catcher | INFO] #5      _BufferingStreamSubscription._sendData (dart:async/stream_impl.dart:341:11)
I/flutter (15609): [2022-03-17 18:46:53.288184 | Catcher | INFO] #6      _DelayedData.perform (dart:async/stream_impl.dart:591:14)
I/flutter (15609): [2022-03-17 18:46:53.288221 | Catcher | INFO] #7      _StreamImplEvents.handleNext (dart:async/stream_impl.dart:706:11)
I/flutter (15609): [2022-03-17 18:46:53.288258 | Catcher | INFO] #8      _PendingEvents.schedule.<anonymous closure> (dart:async/stream_impl.dart:663:7)
I/flutter (15609): [2022-03-17 18:46:53.288296 | Catcher | INFO] #9      _rootRun (dart:async/zone.dart:1420:47)
I/flutter (15609): [2022-03-17 18:46:53.288334 | Catcher | INFO] #10     _CustomZone.run (dart:async/zone.dart:1328:19)
I/flutter (15609): [2022-03-17 18:46:53.288375 | Catcher | INFO] #11     _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
I/flutter (15609): [2022-03-17 18:46:53.288414 | Catcher | INFO] #12     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
I/flutter (15609): [2022-03-17 18:46:53.288453 | Catcher | INFO] #13     _rootRun (dart:async/zone.dart:1428:13)
I/flutter (15609): [2022-03-17 18:46:53.288491 | Catcher | INFO] #14     _CustomZone.run (dart:async/zone.dart:1328:19)
I/flutter (15609): [2022-03-17 18:46:53.288528 | Catcher | INFO] #15     _CustomZone.runGuarded (dart:async/zone.dart:1236:7)
I/flutter (15609): [2022-03-17 18:46:53.288566 | Catcher | INFO] #16     _CustomZone.bindCallbackGuarded.<anonymous closure> (dart:async/zone.dart:1276:23)
I/flutter (15609): [2022-03-17 18:46:53.288605 | Catcher | INFO] #17     _microtaskLoop (dart:async/schedule_microtask.dart:40:21)
I/flutter (15609): [2022-03-17 18:46:53.288644 | Catcher | INFO] #18     _startMicrotaskLoop (dart:async/schedule_microtask.dart:49:5)
I/flutter (15609): [2022-03-17 18:46:53.288681 | Catcher | INFO] 
I/flutter (15609): [2022-03-17 18:46:53.288731 | Catcher | INFO] ======================================================================
I/flutter (15609): [2022-03-17 18:46:53.288950 | Catcher | INFO] Logging to sentry...
I/flutter (15609): [2022-03-17 18:46:53.296705 | Catcher | INFO] Report result: true

The original stack trace start with InAppPurchaseController.onError (package:XXXX/in_app_purchase_controller.dart:210:71)

The log in Sentry: image No matter where the error is catched, StackTrace is always start with sentry_handler.dart in SentryHandler.handle at line 60:26 within catcher

Catcher version

Smartphone (please complete the following information):