79099999

Date: 2024-10-17 22:22:50
Score: 1
Natty:
Report link

In my case it made most sense to just throw the Exception inside the try catch block. I want to do this because I want to make sure that a user is logged in and don't want to handle a nullable User object.

@override
void onNavigation(NavigationResolver resolver, StackRouter router) {
  try {
    final user = ref.watch(firebaseAuthProvider).currentUser;
    if (user == null) {
      throw UserNotSignedInException();
    }
    resolver.next();
  } on UserNotSignedInException {
    logger('User is not logged in, pushing intro route', name: 'IntroGuard');
    router.push(const IntroRoute());
  } catch (e, s) {
    logger(
      'Error navigating to intro route',
      error: e,
      stackTrace: s,
      name: 'IntroGuard',
    );
    router.push(const IntroRoute());
  }
}
Reasons:
  • RegEx Blacklisted phrase (1): I want
  • Long answer (-0.5):
  • Has code block (-0.5):
  • Self-answer (0.5):
  • Low reputation (0.5):
Posted by: Dario Digregorio