Skip to content

Commit 13a0b19

Browse files
authored
feat(core): Error Handling Revamp (#3102)
* 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
1 parent ff4c94d commit 13a0b19

97 files changed

Lines changed: 3431 additions & 2063 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

etc/firebase-admin.api.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,14 @@ export namespace database {
220220
const ServerValue: rtdb.ServerValue;
221221
}
222222

223+
// @public
224+
export interface ErrorInfo {
225+
cause?: Error;
226+
code: string;
227+
httpResponse?: HttpResponse;
228+
message: string;
229+
}
230+
223231
// @public
224232
export interface FirebaseArrayIndexError {
225233
error: FirebaseError;
@@ -228,12 +236,19 @@ export interface FirebaseArrayIndexError {
228236

229237
// @public
230238
export interface FirebaseError {
239+
cause?: Error;
231240
code: string;
241+
httpResponse?: HttpResponse;
232242
message: string;
233243
stack?: string;
234244
toJSON(): object;
235245
}
236246

247+
// @public
248+
export class FirebaseError extends Error implements FirebaseError {
249+
constructor(errorInfo: ErrorInfo);
250+
}
251+
237252
// @public (undocumented)
238253
export function firestore(app?: App): _firestore.Firestore;
239254

@@ -299,6 +314,15 @@ export interface GoogleOAuthAccessToken {
299314
expires_in: number;
300315
}
301316

317+
// @public
318+
export interface HttpResponse {
319+
data?: string | object;
320+
headers: {
321+
[key: string]: any;
322+
};
323+
status: number;
324+
}
325+
302326
// @public (undocumented)
303327
export function initializeApp(options?: AppOptions, name?: string): app.App;
304328

etc/firebase-admin.app-check.api.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ export class AppCheck {
1616
verifyToken(appCheckToken: string, options?: VerifyAppCheckTokenOptions): Promise<VerifyAppCheckTokenResponse>;
1717
}
1818

19+
// @public
20+
export type AppCheckErrorCode = 'aborted' | 'invalid-argument' | 'invalid-credential' | 'internal-error' | 'permission-denied' | 'unauthenticated' | 'not-found' | 'app-check-token-expired' | 'unknown-error';
21+
1922
// @public
2023
export interface AppCheckToken {
2124
token: string;
@@ -39,6 +42,14 @@ export interface DecodedAppCheckToken {
3942
sub: string;
4043
}
4144

45+
// Warning: (ae-forgotten-export) The symbol "PrefixedFirebaseError" needs to be exported by the entry point index.d.ts
46+
//
47+
// @public
48+
export class FirebaseAppCheckError extends PrefixedFirebaseError {
49+
// Warning: (ae-forgotten-export) The symbol "ErrorInfo" needs to be exported by the entry point index.d.ts
50+
constructor(info: ErrorInfo, message?: string);
51+
}
52+
4253
// @public
4354
export function getAppCheck(app?: App): AppCheck;
4455

etc/firebase-admin.app.api.md

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,19 @@ export interface Credential {
6363
// @public
6464
export function deleteApp(app: App): Promise<void>;
6565

66+
// @public
67+
export interface ErrorInfo {
68+
cause?: Error;
69+
code: string;
70+
httpResponse?: HttpResponse;
71+
message: string;
72+
}
73+
6674
// Warning: (ae-forgotten-export) The symbol "PrefixedFirebaseError" needs to be exported by the entry point index.d.ts
6775
//
6876
// @public
6977
export class FirebaseAppError extends PrefixedFirebaseError {
78+
constructor(info: ErrorInfo, message?: string);
7079
}
7180

7281
// @public
@@ -77,12 +86,19 @@ export interface FirebaseArrayIndexError {
7786

7887
// @public
7988
export interface FirebaseError {
89+
cause?: Error;
8090
code: string;
91+
httpResponse?: HttpResponse;
8192
message: string;
8293
stack?: string;
8394
toJSON(): object;
8495
}
8596

97+
// @public
98+
export class FirebaseError extends Error implements FirebaseError {
99+
constructor(errorInfo: ErrorInfo);
100+
}
101+
86102
// @public
87103
export function getApp(appName?: string): App;
88104

@@ -97,6 +113,15 @@ export interface GoogleOAuthAccessToken {
97113
expires_in: number;
98114
}
99115

116+
// @public
117+
export interface HttpResponse {
118+
data?: string | object;
119+
headers: {
120+
[key: string]: any;
121+
};
122+
status: number;
123+
}
124+
100125
// @public
101126
export function initializeApp(options?: AppOptions, appName?: string): App;
102127

0 commit comments

Comments
 (0)