You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To handle Firebase errors in a generic way I had to do dangerous type assertions to calm TypeScript down.
Firestore is a part of Firebase but, according to TypeScript, FirestoreError is not a FirebaseError.
But AuthErroris a FirebaseError, just like StorageError (looks like at least).
But StorageError has a special attribute serverResponse, not nested into customData like AuthError does…
Wat?
Here are the incriminated TypeScript interfaces:
/** An error returned by a Firestore operation. */exportdeclareclassFirestoreErrorextendsError{/** * The backend error code associated with this error. */readonlycode: FirestoreErrorCode;/** * A custom error description. */readonlymessage: string;/** The custom name for all FirestoreErrors. */readonlyname: string;/** The stack of the error. */readonlystack?: string;privateconstructor();}
/** * Interface for an `Auth` error. * * @public */exportdeclareinterfaceAuthErrorextendsFirebaseError{/** Details about the Firebase Auth error. */readonlycustomData: {/** The name of the Firebase App which triggered this error. */readonlyappName: string;/** The email address of the user's account, used for sign-in and linking. */readonlyemail?: string;/** The phone number of the user's account, used for sign-in and linking. */readonlyphoneNumber?: string;/** * The tenant ID being used for sign-in and linking. * * @remarks * If you use {@link signInWithRedirect} to sign in, * you have to set the tenant ID on the {@link Auth} instance again as the tenant ID is not persisted * after redirection. */readonlytenantId?: string;};}
/** * An error returned by the Firebase Storage SDK. * @public */exportdeclareinterfaceStorageError{/** * A server response message for the error, if applicable. */serverResponse: string|null;code: string;customData?: Record<string,unknown>;name: 'FirebaseError';message: string;stack?: string;}
Could it be possible for FirestoreError to actually be a FirebaseError just like other Firebase errors?
Would it be possible for all FirebaseError, including StorageError, to simply have code, name, message and stack attributes, and all other error details nested into customData (as it was done for AuthError)?
That would make my day.
Cheers,
Laurent
The text was updated successfully, but these errors were encountered:
[REQUIRED] Describe your environment
[REQUIRED] Describe the problem
To handle Firebase errors in a generic way I had to do dangerous type assertions to calm TypeScript down.
Firestore is a part of Firebase but, according to TypeScript,
FirestoreError
is not aFirebaseError
.But
AuthError
is aFirebaseError
, just likeStorageError
(looks like at least).But
StorageError
has a special attributeserverResponse
, not nested intocustomData
likeAuthError
does…Wat?
Here are the incriminated TypeScript interfaces:
So two little requests 🙏
FirestoreError
to actually be aFirebaseError
just like other Firebase errors?FirebaseError
, includingStorageError
, to simply havecode
,name
,message
andstack
attributes, and all other error details nested intocustomData
(as it was done forAuthError
)?That would make my day.
Cheers,
Laurent
The text was updated successfully, but these errors were encountered: