Skip to content

[firebase_ai]: QuotaExceeded and ServiceApiNotEnabled exceptions are not exported #17927

@htsuruo

Description

@htsuruo

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Other

Which platforms are affected?

iOS, Android, macOS, Web, Windows

Description

Bug report

The QuotaExceeded and ServiceApiNotEnabled exception classes are defined in src/error.dart but are not exported from the main firebase_ai.dart barrel file.

This makes it impossible to catch these specific exceptions in user code.

Expected behavior

QuotaExceeded and ServiceApiNotEnabled should be exported like other exception classes (InvalidApiKey, ServerException, UnsupportedUserLocation).

Current export in firebase_ai.dart:

export 'src/error.dart'
    show
        FirebaseAIException,
        FirebaseAISdkException,
        InvalidApiKey,
        ServerException,
        UnsupportedUserLocation;

Suggested fix:

export 'src/error.dart'
    show
        FirebaseAIException,
        FirebaseAISdkException,
        InvalidApiKey,
        QuotaExceeded,          // Add this
        ServerException,
        ServiceApiNotEnabled,   // Add this
        UnsupportedUserLocation;

Reproducing the issue

import 'package:firebase_ai/firebase_ai.dart';

try {
  // Call Firebase AI API
} on QuotaExceeded catch (e) {  //  Error: 'QuotaExceeded' isn't defined
  // Handle quota exceeded
}

Firebase Core version

4.2.1

Flutter Version

3.38.1

Relevant Log Output

Flutter dependencies

Expand Flutter dependencies snippet
Replace this line with the contents of your `flutter pub deps -- --style=compact`.

Additional context and comments

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs AttentionThis issue needs maintainer attention.platform: allIssues / PRs which are for all platforms.plugin: ailabel issues for firebase_ai plugintype: bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions