Exception castAndReturnPlatformException()

in packages/amplify_auth_cognito/lib/amplify_auth_error_handling.dart [21:178]


Exception castAndReturnPlatformException(PlatformException e) {
  switch (e.code) {
    case "AliasExistsException":
      {
        return AliasExistsException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "CodeDeliveryFailureException":
      {
        return CodeDeliveryFailureException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "CodeExpiredException":
    case "CognitoCodeExpiredException":
      {
        return CodeExpiredException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "CodeMismatchException":
      {
        return CodeMismatchException.fromMap(
            Map<String, String>.from(e.details));
      }
    case 'ConfigurationException':
      return InvalidUserPoolConfigurationException.fromMap(e.details as Map);
    case 'DeviceNotTrackedException':
      return DeviceNotTrackedException.fromMap(e.details as Map);
    case "FailedAttemptsLimitExceededException":
      {
        return FailedAttemptsLimitExceededException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "InternalErrorException":
      {
        return InternalErrorException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "InvalidAccountTypeException":
      {
        return InvalidAccountTypeException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "InvalidParameterException":
      {
        return InvalidParameterException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "InvalidPasswordException":
      {
        return InvalidPasswordException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "InvalidStateException":
      {
        return InvalidStateException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "LambdaException":
      {
        return LambdaException.fromMap(Map<String, String>.from(e.details));
      }
    case "LimitExceededException":
      {
        return LimitExceededException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "MFAMethodNotFoundException":
      {
        return MFAMethodNotFoundException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "NotAuthorizedException":
      {
        return NotAuthorizedException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "PasswordResetRequiredException":
      {
        return PasswordResetRequiredException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "ResourceNotFoundException":
      {
        return ResourceNotFoundException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "SessionExpiredException":
      {
        return SessionExpiredException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "SessionUnavailableOfflineException":
      {
        return SessionUnavailableOfflineException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "SessionUnavailableServiceException":
      {
        return SessionUnavailableServiceException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "SignedOutException":
      {
        return SignedOutException.fromMap(Map<String, String>.from(e.details));
      }
    case "SoftwareTokenMFANotFoundException":
      {
        return SoftwareTokenMFANotFoundException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "TooManyFailedAttemptsException":
      {
        return TooManyFailedAttemptsException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "TooManyRequestsException":
      {
        return TooManyRequestsException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "UnknownException":
      {
        return UnknownException.fromMap(Map<String, String>.from(e.details));
      }
    case "UserCancelledException":
      {
        return UserCancelledException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "UsernameExistsException":
      {
        return UsernameExistsException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "UserNotConfirmedException":
      {
        return UserNotConfirmedException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "UserNotFoundException":
      {
        return UserNotFoundException.fromMap(
            Map<String, String>.from(e.details));
      }
    case "AuthException":
      {
        return AuthException.fromMap(Map<String, String>.from(e.details));
      }
    case "AmplifyException":
      {
        return AmplifyException.fromMap(Map<String, String>.from(e.details));
      }
    default:
      {
        return e;
      }
  }
}