Untitled
unknown
plain_text
a year ago
2.2 kB
9
Indexable
Future<T> _executeWithErrorHandling<T>(Future<T> Function() action,
{required String type}) async {
try {
return await action();
} on FirebaseAuthException catch (e) {
String errorMessage;
switch (e.code) {
case 'invalid-credential':
errorMessage = UTUAStrings.invalidCredential.i18n;
break;
case 'user-disabled':
errorMessage = UTUAStrings.userDisabled.i18n;
break;
case 'operation-not-allowed':
errorMessage = UTUAStrings.operationNotAllowed.i18n;
break;
case 'account-exists-with-different-credential':
errorMessage = UTUAStrings.accountExistsWithDifferentCredential.i18n;
break;
case 'invalid-verification-code':
errorMessage = UTUAStrings.invalidVerificationCode.i18n;
break;
case 'invalid-verification-id':
errorMessage = UTUAStrings.invalidVerificationId.i18n;
break;
case 'user-not-found':
errorMessage = UTUAStrings.userNotFound.i18n;
break;
case 'wrong-password':
errorMessage = UTUAStrings.wrongPassword.i18n;
break;
case 'weak-password':
errorMessage = UTUAStrings.weakPassword.i18n;
break;
default:
errorMessage = UTUAStrings.unknownError.i18n;
break;
}
throw ServerException(
path: e.code,
type: type,
message: errorMessage,
);
} on PlatformException catch (e) {
String errorMessage;
switch (e.code) {
case 'network_error':
errorMessage = UTUAStrings.networkError.i18n;
break;
case 'sign_in_failed':
errorMessage = UTUAStrings.signInFailed.i18n;
break;
default:
errorMessage = UTUAStrings.unknownError.i18n;
break;
}
throw ServerException(
path: e.code,
type: type,
message: errorMessage,
);
} catch (e) {
throw ServerException(
path: '',
type: type,
message: UTUAStrings.unknownError.i18n,
);
}
}Editor is loading...
Leave a Comment