Repository navigation
Conversation
There was a problem hiding this comment.
Code Review
This pull request updates the React authentication form action hooks (useEmailLinkAuthFormAction, useForgotPasswordAuthFormAction, useSignInAuthFormAction, and useSignUpAuthFormAction) to rethrow the original FirebaseUIError instance directly rather than wrapping its message in a generic Error. This change ensures that critical error properties, such as code and cause, are preserved for callers. Additionally, corresponding unit tests have been added to verify this behavior across all modified forms. I have no further feedback to provide as the changes are well-implemented and fully tested.
russellwheatley
left a comment
There was a problem hiding this comment.
A couple of things on the ui/unknown-error shape.
| */ | ||
| export function createUnknownFirebaseUIError(ui: FirebaseUI, error: unknown): FirebaseUIError { | ||
| const unknownError = new FirebaseError("ui/unknown-error", getTranslation(ui, "errors", "unknownError")); | ||
| unknownError.cause = error; |
There was a problem hiding this comment.
For ui/unknown-error the original error ends up at err.cause.cause, and err.cause is a synthetic FirebaseError with the translated message. That doesn't quite match the README errors section ("keep the original Firebase error as cause... untranslated message"). Might be worth a line in that README section saying where to find the original for ui/unknown-error, or I'm open to a flatter shape if you think it's cleaner.
There was a problem hiding this comment.
Flattened it: err.cause now carries the original error's untranslated message, with the original error at err.cause.cause, and the README errors section says so.
| * @param error - The original error. | ||
| * @returns A FirebaseUIError for the unknown error. | ||
| */ | ||
| export function createUnknownFirebaseUIError(ui: FirebaseUI, error: unknown): FirebaseUIError { |
There was a problem hiding this comment.
Since ui/unknown-error is now a code consumers can see, I think this helper might belong in core next to FirebaseUIError so Angular (or anything else) can produce the same error.
There was a problem hiding this comment.
Agreed, moved to core as createUnknownFirebaseUIError next to FirebaseUIError, and ui/unknown-error now maps to unknownError in ERROR_CODE_MAP.
Makes the sign-in, sign-up, forgot-password and email-link action hooks always reject with a
FirebaseUIError, so React apps keep itscodeandcauseinstead of getting a plainError.Changes
use*AuthFormActionhooks rethrow theFirebaseUIErroras-is, matching the phone and MFA hooks. The message users see is unchanged.FirebaseUIErrorfrom the new corecreateUnknownFirebaseUIError: codeui/unknown-error, the translatedunknownErrormessage, the original message oncauseand the original error atcause.cause.instanceof Errorare unaffected.ui/unknown-errorshape and the hooks' rejection type.Maintainer note: Fixes internal CPRN-506