feat(core): Error Handling Revamp (v14)#3140
Conversation
* Initial exports and external api changes * Connect response to error info * feat: Revamp error handling to include `httpResponse` and `cause` in `FirebaseAuthError` and `FirebaseAppError`, added sample tests. * more refactoring * refactor: Update all services to use ErrorInfo format * refactor: Update unit tests to verify error cause and httpResponse population. * chore: fix lint * chore: remove debug tests * fix: Ran api documentor and fix some export errors * fix: Removed outdated `__proto__` workaround and updated api doc strings * chore: Fix lint * fix: Used a helper function to map `RequestResponse` to `HttpResponse` * fix: Removed last of the stringified response bodies in response messages * chore: Fix lint * chore: Generate apidocs * fix: Apply revamp changes to pnv * chore: Added review suggestions
… enable declaration merging (#3127) * chore(auth): Refactor auth error logic * chore(installations): Refactor installations and instance id error logic * chore(fcm): Refactor fcm error logic * fix(auth): Fix auth error mapping that were not copied correctly * fix(auth): Fixed `INVALID_SERVICE_ACCOUNT` to map to a valid client code * chore(pm): Refactor project management error logic * chore: Fix license year for new files * chore(rtdb): Refactor rtdb error logic * chore(fs): Refactor firestore error logic * chore(app): Refactor app error logic * chore(security-rules): Refactor security rules error logic * chore(app-check): Refactor app check error logic * chore(remote-config): Refactor remote config error logic * chore(functions): Refactor functions error logic * chore(extensions): Refactor extensions error logic * chore(fdc): Refactor data connect error logic * chore(ml): Refactor ml error logic * chore(eventarc): Refactor eventarc error logic * chore(fpnv): Refactor pnv error logic * fix: address gemini review * fix: Use Declaration Merging to expose error code constant mapping along side error code type * fix: Address gemini review * chore: Remove extra whitespace
* feat(messaging): Improve HTTP/2 session error handling. * fix: ensure error causes are not lost * fix: clean up stale tests * fix: address gemini review * fix: address more gemini review * fix: Resolve leftover merge issues
There was a problem hiding this comment.
Code Review
This pull request refactors the SDK's error handling system by introducing a standardized ErrorInfo interface that includes HTTP response data and underlying error causes. Service-specific error classes now extend PrefixedFirebaseError and utilize object-based constructors. The messaging service's HTTP/2 logic was also updated to aggregate session errors into batch responses. Feedback identifies opportunities to improve AggregateError serialization in toJSON(), remove the obsolete FirebaseMessagingSessionError class, and refine error message formatting within the HTTP/2 session handler.
egilmorez
left a comment
There was a problem hiding this comment.
Just a couple nits, thanks!
| export type FunctionsErrorCode = typeof FunctionsErrorCode[keyof typeof FunctionsErrorCode]; | ||
|
|
||
| /** | ||
| * Firebase Functions error code structure. This extends PrefixedFirebaseError. |
There was a problem hiding this comment.
Splitting hairs, but no never "Firebase Functions" capitalized. Go with Cloud Functions.
This PR makes changes the usage and handling of Firebase Errors and includes the following changes:
FirebaseErrorclass.error.tsfiles, utilizing declaration merging to improve IDE autocomplete and indexing.ErrorInfoandHttpResponseclasses for better error handing.ErrorInfoFirebaseErrors:causeandHttpResponse.causeattribute onFirebaseErrorsto allow failing of request at the stream level with context on session error cause.FirebaseMessagingSessionErrorand its logic.This PR had mostly been previously reviewed in: #3102, #3140 and #3126