Skip to content

[google_sign_in] better error handling #32441

@mrdavidrees

Description

@mrdavidrees

Currently the way that errors are handled in the ObjC google_sign_in package makes it hard to identify the core issue at hand.

if, for example, the url scheme if not provided in the iOS app info.plist an error is generated by GIDSignIn, when this error is caught it is passed back to flutter the error message is lost and instead it returns a more generic error message without much information.

The error is caught on GoogleSignInPlugin.m, line 96

 @try {
    [[GIDSignIn sharedInstance] signIn];
  } @catch (NSException *e) {
    result([FlutterError errorWithCode:@"google_sign_in" message:e.reason details:e.name]);
    [e raise];
  }

The error currently logged in the flutter debug output
*** First throw call stack:

(
	0   CoreFoundation                      0x00000001057d71bb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x0000000104901735 objc_exception_throw + 48
	2   CoreFoundation                      0x00000001057d7015 +[NSException raise:format:] + 197
	3   Runner                              0x000000010066aef9 -[GIDSignIn signInWithOptions:] + 242
	4   Runner                              0x00000001006674ee -[GIDSignIn signIn] + 64
	5   Runner                              0x000000010057324b -[FLTGoogleSignInPlugin handleMethodCall:result:] + 2251
	6   Flutter                             0x0000000102d357ba __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 115

The error currently being logged by the Xcode output

Runner[18549:1040761] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Your app is missing support for the following URL schemes: com.googleusercontent.apps000000000000-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'

*** First throw call stack:

(
	0   CoreFoundation                      0x0000000113a501bb __exceptionPreprocess + 331
	1   libobjc.A.dylib                     0x0000000112b72735 objc_exception_throw + 48
	2   CoreFoundation                      0x0000000113a50015 +[NSException raise:format:] + 197
	3   Runner                              0x000000010e75cef9 -[GIDSignIn signInWithOptions:] + 242
	4   Runner                              0x000000010e7594ee -[GIDSignIn signIn] + 64
	5   Runner                              0x000000010e66524b -[FLTGoogleSignInPlugin handleMethodCall:result:] + 2251
	6   Flutter                             0x000000010fabd7ba __45-[FlutterMethodChannel setMethodCallHandler:]_block_invoke + 115
	7   Flutter                             0x000000010fada4ac _ZNK5shell21PlatformMessageRouter21HandlePlatformMessageEN3fml6RefPtrIN5blink15PlatformMessageEEE + 166
	8   Flutter                             0x000000010faddff0 _ZN5shell15PlatformViewIOS21HandlePlatformMessageEN3fml6RefPtrIN5blink15PlatformMessageEEE + 38
	9   Flutter                             0x000000010fb30ca7 _ZNSt3__110__function6__funcIZN5shell5Shell29OnEngineHandlePlatformMessageEN3fml6RefPtrIN5blink15PlatformMessageEEEE4$_27NS_9allocatorIS9_EEFvvEEclEv + 57
	10  Flutter                             0x000000010fae9e0e _ZN3fml15MessageLoopImpl15RunExpiredTasksEv + 522
	11  Flutter                             0x000000010faed18c _ZN3fml17MessageLoopDarwin11OnTimerFireEP16__CFRunLoopTimerPS0_ + 26
	12  CoreFoundation                      0x00000001139b5f34 __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 20
	13  CoreFoundation                      0x00000001139b5b32 __CFRunLoopDoTimer + 1026
	14  CoreFoundation                      0x00000001139b539a __CFRunLoopDoTimers + 266
	15  CoreFoundation                      0x00000001139afa1c __CFRunLoopRun + 2252
	16  CoreFoundation                      0x00000001139aee11 CFRunLoopRunSpecific + 625
	17  GraphicsServices                    0x00000001180c11dd GSEventRunModal + 62
	18  UIKitCore                           0x000000011ba9681d UIApplicationMain + 140
	19  Runner                              0x000000010e441850 main + 112
	20  libdyld.dylib                       0x0000000114b7b575 start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException

This may not be specific to this plugin but I'm sure it will help future users if the error handling provides a more clear description of the error.

Metadata

Metadata

Labels

P2Important issues not at the top of the work lista: error messageError messages from the Flutter frameworkp: google_sign_inThe Google Sign-In pluginpackageflutter/packages repository. See also p: labels.platform-iosiOS applications specificallyteam-iosOwned by iOS platform teamtriaged-iosTriaged by iOS platform team

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions