55import 'package:firebase_auth_platform_interface/firebase_auth_platform_interface.dart' ;
66import 'package:firebase_auth_platform_interface/src/method_channel/method_channel_firebase_auth.dart' ;
77import 'package:firebase_auth_platform_interface/src/method_channel/method_channel_user_credential.dart' ;
8+ import 'package:firebase_auth_platform_interface/src/method_channel/utils/exception.dart' ;
89import 'package:firebase_auth_platform_interface/src/method_channel/utils/pigeon_helper.dart' ;
910import 'package:firebase_auth_platform_interface/src/pigeon/messages.pigeon.dart' ;
1011
@@ -16,8 +17,12 @@ class MethodChannelMultiFactor extends MultiFactorPlatform {
1617
1718 @override
1819 Future <MultiFactorSession > getSession () async {
19- final pigeonObject = await _api.getSession (auth.app.name);
20- return MultiFactorSession (pigeonObject.id);
20+ try {
21+ final pigeonObject = await _api.getSession (auth.app.name);
22+ return MultiFactorSession (pigeonObject.id);
23+ } catch (e, stack) {
24+ convertPlatformException (e, stack, fromPigeon: true );
25+ }
2126 }
2227
2328 @override
@@ -39,14 +44,18 @@ class MethodChannelMultiFactor extends MultiFactorPlatform {
3944 throw ArgumentError ('verificationId must not be null' );
4045 }
4146
42- await _api.enrollPhone (
43- auth.app.name,
44- PigeonPhoneMultiFactorAssertion (
45- verificationId: verificationId,
46- verificationCode: verificationCode,
47- ),
48- displayName,
49- );
47+ try {
48+ await _api.enrollPhone (
49+ auth.app.name,
50+ PigeonPhoneMultiFactorAssertion (
51+ verificationId: verificationId,
52+ verificationCode: verificationCode,
53+ ),
54+ displayName,
55+ );
56+ } catch (e, stack) {
57+ convertPlatformException (e, stack, fromPigeon: true );
58+ }
5059 } else {
5160 throw UnimplementedError (
5261 'Credential type ${_assertion .credential } is not supported yet' ,
@@ -66,16 +75,24 @@ class MethodChannelMultiFactor extends MultiFactorPlatform {
6675 );
6776 }
6877
69- return _api.unenroll (
70- auth.app.name,
71- uidToUnenroll,
72- );
78+ try {
79+ return _api.unenroll (
80+ auth.app.name,
81+ uidToUnenroll,
82+ );
83+ } catch (e, stack) {
84+ convertPlatformException (e, stack, fromPigeon: true );
85+ }
7386 }
7487
7588 @override
7689 Future <List <MultiFactorInfo >> getEnrolledFactors () async {
77- final data = await _api.getEnrolledFactors (auth.app.name);
78- return multiFactorInfoPigeonToObject (data);
90+ try {
91+ final data = await _api.getEnrolledFactors (auth.app.name);
92+ return multiFactorInfoPigeonToObject (data);
93+ } catch (e, stack) {
94+ convertPlatformException (e, stack, fromPigeon: true );
95+ }
7996 }
8097}
8198
@@ -112,18 +129,22 @@ class MethodChannelMultiFactorResolver extends MultiFactorResolverPlatform {
112129 throw ArgumentError ('verificationId must not be null' );
113130 }
114131
115- final data = await _api.resolveSignIn (
116- _resolverId,
117- PigeonPhoneMultiFactorAssertion (
118- verificationId: verificationId,
119- verificationCode: verificationCode,
120- ),
121- );
122-
123- MethodChannelUserCredential userCredential =
124- MethodChannelUserCredential (_auth, data.cast <String , dynamic >());
125-
126- return userCredential;
132+ try {
133+ final data = await _api.resolveSignIn (
134+ _resolverId,
135+ PigeonPhoneMultiFactorAssertion (
136+ verificationId: verificationId,
137+ verificationCode: verificationCode,
138+ ),
139+ );
140+
141+ MethodChannelUserCredential userCredential =
142+ MethodChannelUserCredential (_auth, data.cast <String , dynamic >());
143+
144+ return userCredential;
145+ } catch (e, stack) {
146+ convertPlatformException (e, stack, fromPigeon: true );
147+ }
127148 } else {
128149 throw UnimplementedError (
129150 'Credential type ${_assertion .credential } is not supported yet' ,
0 commit comments