#[SOLVED] Flutter Uncaught Error does not sent into Sentry

21 messages · Page 1 of 1 (latest)

shell dune
#

Hi everyone, I was trying to integrate sentry in a flutter app, I've been successfully sending sentry error log when setting up which is using:

    exception,
    stackTrace: stackTrace,
  );

But I think after setting up the Sentry, it should've always send the error to Sentry right? I don't have to add Sentry.captureException whenever I have error?

This is my initialization on Flutter's app:

await SentryFlutter.init(
            (options) {
              options
                ..dsn =
                    'https://xxx.ingest.us.sentry.io/x'
                ..tracesSampleRate = 1.0
                ..profilesSampleRate = 1.0
                ..enableTimeToFullDisplayTracing = true;
            },
            appRunner: _runApp,
          );

Thanks everyone.

#

Here's the screenshot of my Sentry page, it only shows the one that I've got from sending Sentry.captureException, and the other one is a Overflow error (this one is automatic)

nocturne kernel
#

It depends, is the error you are missing one you capture with a try/catch block? Because if so, then yes you need Sentry.captureException. If the exception is "unhandled" like in the case of the overflow example it will be caught by Flutter en thus sent to Sentry. But if you use a try/catch block the error will never reach any error handling and thus Sentry cannot record it.

shell dune
#

Which will cause FormatException: Invalid radix-10 number (at character 1)

#

By the way, my project also implement Crashlytics, do you think it's not sending to Sentry because it's already sent into Crashlytics?

nocturne kernel
#

I am not a 100% sure if that matters... I would say the FormatException should be captured by Sentry as long as the error is not captured somewhere first. But if Crashlytics interfered I would have expected the overflow error also to not be captured.

#

But I've never had both in a single project so I can't be a 100% certain.

#

It is easy to comment out as much Crashlytics setup code as possible?

#

Just to rule it out

shell dune
nocturne kernel
#

No problem and yeah let us know if that fixes it, maybe there is something specific going on.

shell dune
#

Hi Alex, it turns out that even when I turned off the crashlytics report, it still won't send the report to the Sentry

#

But I am using runZonedGuards in main app that has is (error, stack) function itself, do you think this can affect the functionality? I think i've seen that underneat the Sentry.init, it actually uses the runZonedGuards again.

runZonedGuarded<Future<void>>(
      () async {
// some other setup
await SentryFlutter.init(
            (options) {
              options
                ..dsn =
                    'https://xxx.ingest.us.sentry.io/xxx'
                ..tracesSampleRate = 1.0
                ..profilesSampleRate = 1.0
                ..enableTimeToFullDisplayTracing = true;
            },
            appRunner: _runApp,
          );
     },
(error, stack) {
        if (!kIsWeb) {
          // FirebaseCrashlytics.instance.recordError(error, stack);
        }
      },
);
nocturne kernel
#

Maybe @acoustic violet can also share some questions to help get to the bottom of this.

acoustic violet
#

hey @shell dune i just tested it and added final number = int.parse('aa'); to the sentry example app. as alex said, this exception will be sent automatically to sentry. i will test it with the runZonedGuarded now.

shell dune
#

Hi, I think I've finally succeded to test the error and it was sent into Sentry. I think the problem lies on my code where I call it, somehow I think there's a try catch inside that previous code that makes it looks like already handled.

#

I was calling it inside a BottomSheet, but I can't see any try catch block. But when I try to call it somewhere else, the error is reported. I think there's a problem with my Bottom Sheet that it actually has a try catch

acoustic violet
#

I am glad that you figured it out 👍

shell dune
#

Thanks for the help, sorry for taking your time guys

acoustic violet
#

No worries. This happened to me as well 😅 I believe to every developer at least once. Have a nice day.