Firebase file storage error handling
If you're serious about your next big product or application, you will instantly recognize that the proper showcasing of error on the client side is a serious and urgent matter. In this recipe, I will demonstrate how you can get and read Firebase Storage errors properly.
If you recognized the pattern we used throughout the recipes, you will probably find out--even if you're not familiar with JavaScript's promises--that we're getting all our error message from Firebase in the catchphrase.
Note
JavaScript promise APIs are relatively new APIs shipped in the ES2015. You can read more about them, and how you can implement them within your own code, here: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Promise.
How to do it...
- Let's look at an example. Suppose we're deleting a file; let's now see how we can formulate our error messages based on the error type:
//Deleting an image from the bucket.
imageRef.getMetadata...