Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[📚] Firebase Storage exceptions / error handling #7474

Open
Tom3652 opened this issue Dec 6, 2021 · 4 comments
Open

[📚] Firebase Storage exceptions / error handling #7474

Tom3652 opened this issue Dec 6, 2021 · 4 comments
Labels
good first issue Good for newcomers Needs Attention This issue needs maintainer attention. platform: all Issues / PRs which are for all platforms. plugin: storage type: documentation Improvements or additions to documentation

Comments

@Tom3652
Copy link

Tom3652 commented Dec 6, 2021

I would like to be able to catch and respond according to specific errors from firebase_storage in my Flutter app.

Here is what i would like to do:

UploadTask task = FirebaseStorage.instance.reference().putFile("filePath");
task.catchError((FirebaseStorageException exception) {
  switch (exception.state) {
    case FirebaseStorageExceptionState.unknown:
       break;
    case FirebaseStorageExceptionState.canceled:
       break;
    ...
  }
})

For now i saw only 1 line in the documentation :

Future<void> uploadFile(String filePath) async {
  File file = File(filePath);

  try {
    await firebase_storage.FirebaseStorage.instance
        .ref('uploads/file-to-upload.png')
        .putFile(file);
  } on firebase_core.FirebaseException catch (e) {
    // e.g, e.code == 'canceled'
  }
}

Saying e.code == 'canceled'. Fine, but what are the others String we should catch as code please ?

I think all of the error codes should be added, or an enum describing the error state would also be great if possible.

@Tom3652 Tom3652 added good first issue Good for newcomers type: documentation Improvements or additions to documentation labels Dec 6, 2021
@darshankawar darshankawar added triage Issue is currently being triaged. plugin: storage and removed triage Issue is currently being triaged. labels Dec 7, 2021
@Ehesp
Copy link
Member

Ehesp commented Dec 8, 2021

This is related; #3402 (comment)

We had a lot of back and forth on doing enums - the issue is we wrap the native SDKs and simply pass on the error code, so we're not actually 100% sure on what all of those error codes could be, especially given different platforms have different codes.

I'll revive the chat and see if we can implement something at least.

@Tom3652
Copy link
Author

Tom3652 commented Dec 8, 2021

Thanks for the reply @Ehesp and the link, i understand better now this issue.
Anyway it would be awesome if something would come up :)

@darshankawar
Copy link

@Tom3652
Can you check if this documentation helps and addresses your issue ?

@darshankawar darshankawar added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Dec 14, 2022
@Tom3652
Copy link
Author

Tom3652 commented Dec 14, 2022

Yes @darshankawar it answers my needs for the second part of the question, but it's a real work for developers to follow the updates.

It would be much easier for us to deal with enums and let Firebase do internally the mapping when they update the SDKs in my opinion, but would be more work to be done on FlutterFire to test and update the code values when the native SDKs are updated if needed

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Dec 14, 2022
@Lyokone Lyokone added the platform: all Issues / PRs which are for all platforms. label Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers Needs Attention This issue needs maintainer attention. platform: all Issues / PRs which are for all platforms. plugin: storage type: documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

5 participants