Skip to content

Commit 544a449

Browse files
authored
feat(error): Decouple public error codes, modularize error files, and 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
1 parent 13a0b19 commit 544a449

138 files changed

Lines changed: 2904 additions & 2607 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.

.eslintrc.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,15 @@ module.exports = {
7171
"selector": "variable",
7272
"format": ["camelCase", "UPPER_CASE"]
7373
},
74+
{
75+
"selector": "variable",
76+
"modifiers": ["const"],
77+
"format": ["PascalCase", "camelCase", "UPPER_CASE"],
78+
"filter": {
79+
"regex": "ErrorCode$", // Matches only if it ends exactly with ErrorCode
80+
"match": true,
81+
},
82+
},
7483
{
7584
"selector": "parameter",
7685
"format": ["camelCase"],

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

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,20 @@ export class AppCheck {
1717
}
1818

1919
// @public
20-
export type AppCheckErrorCode = 'aborted' | 'invalid-argument' | 'invalid-credential' | 'internal-error' | 'permission-denied' | 'unauthenticated' | 'not-found' | 'app-check-token-expired' | 'unknown-error';
20+
export const AppCheckErrorCode: {
21+
readonly ABORTED: "aborted";
22+
readonly INVALID_ARGUMENT: "invalid-argument";
23+
readonly INVALID_CREDENTIAL: "invalid-credential";
24+
readonly INTERNAL: "internal-error";
25+
readonly PERMISSION_DENIED: "permission-denied";
26+
readonly UNAUTHENTICATED: "unauthenticated";
27+
readonly NOT_FOUND: "not-found";
28+
readonly APP_CHECK_TOKEN_EXPIRED: "app-check-token-expired";
29+
readonly UNKNOWN: "unknown-error";
30+
};
31+
32+
// @public
33+
export type AppCheckErrorCode = typeof AppCheckErrorCode[keyof typeof AppCheckErrorCode];
2134

2235
// @public
2336
export interface AppCheckToken {

etc/firebase-admin.app.api.md

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -13,30 +13,22 @@ export interface App {
1313
}
1414

1515
// @public
16-
export class AppErrorCodes {
17-
// (undocumented)
18-
static APP_DELETED: string;
19-
// (undocumented)
20-
static DUPLICATE_APP: string;
21-
// (undocumented)
22-
static INTERNAL_ERROR: string;
23-
// (undocumented)
24-
static INVALID_APP_NAME: string;
25-
// (undocumented)
26-
static INVALID_APP_OPTIONS: string;
27-
// (undocumented)
28-
static INVALID_ARGUMENT: string;
29-
// (undocumented)
30-
static INVALID_CREDENTIAL: string;
31-
// (undocumented)
32-
static NETWORK_ERROR: string;
33-
// (undocumented)
34-
static NETWORK_TIMEOUT: string;
35-
// (undocumented)
36-
static NO_APP: string;
37-
// (undocumented)
38-
static UNABLE_TO_PARSE_RESPONSE: string;
39-
}
16+
export const AppErrorCode: {
17+
readonly APP_DELETED: "app-deleted";
18+
readonly DUPLICATE_APP: "duplicate-app";
19+
readonly INVALID_ARGUMENT: "invalid-argument";
20+
readonly INTERNAL_ERROR: "internal-error";
21+
readonly INVALID_APP_NAME: "invalid-app-name";
22+
readonly INVALID_APP_OPTIONS: "invalid-app-options";
23+
readonly INVALID_CREDENTIAL: "invalid-credential";
24+
readonly NETWORK_ERROR: "network-error";
25+
readonly NETWORK_TIMEOUT: "network-timeout";
26+
readonly NO_APP: "no-app";
27+
readonly UNABLE_TO_PARSE_RESPONSE: "unable-to-parse-response";
28+
};
29+
30+
// @public
31+
export type AppErrorCode = typeof AppErrorCode[keyof typeof AppErrorCode];
4032

4133
// @public
4234
export function applicationDefault(httpAgent?: Agent): Credential;

0 commit comments

Comments
 (0)