firebase-js-sdk icon indicating copy to clipboard operation
firebase-js-sdk copied to clipboard

SDKs should be consistent with the errors class/interface

Open jshcrowthe opened this issue 9 years ago • 5 comments

[REQUIRED] Describe your environment

  • Operating System version: n/a
  • Firebase SDK version: n/a
  • Firebase Product: auth, database, storage

[REQUIRED] Describe the problem

We provide an error class (FirebaseError) that we should be using cross SDK to be more consistent with our Error reporting.

Steps to reproduce:

n/a

Relevant Code:

All error implementatinos

cc: @sphippen, @bojeil-google, @schmidt-sebastian

jshcrowthe avatar Jun 26 '17 17:06 jshcrowthe

Storage errors have a string property "serverResponse" that contains the body of the server's response (if the error was generated based on a server response) which can be useful for debugging. In fact, some of Storage's error messages tell the user to inspect "serverResponse" for more info.

@jshcrowthe @bojeil-google @schmidt-sebastian Would it make sense to add something like this to FirebaseError? Would other features use it if they already have something similar? I don't want to switch the error implementation until we find a suitable replacement for that property.

sphippen avatar Jun 27 '17 22:06 sphippen

From the perspective of FirebaseError I think it makes a lot of sense to allow for custom meta fields. That's something we could totally do.

Then each component can leverage the same base error, and extend it as they please.

jshcrowthe avatar Jun 27 '17 23:06 jshcrowthe

Auth error is quite complicated. Auth errors can contain additional data in some cases. For example when the credential already exists, an email or phoneNumber and an optional credential can be returned. The only time we return the server response is for cryptic internal-error where we stringify the entire server response and return it in the error message.

bojeil-google avatar Jun 27 '17 23:06 bojeil-google

@bojeil-google if FirebaseError supported arbitrary "meta" fields, would that suit your use case?

jshcrowthe avatar Jun 28 '17 00:06 jshcrowthe

Closing this, will open a larger "Consolidate all the things" Issue where I will try and identify some duplication we can address.

jshcrowthe avatar Oct 04 '17 17:10 jshcrowthe