Skip to content

feat(core): Error Handling Revamp#3102

Draft
jonathanedey wants to merge 9 commits intomainfrom
je-error-re
Draft

feat(core): Error Handling Revamp#3102
jonathanedey wants to merge 9 commits intomainfrom
je-error-re

Conversation

@jonathanedey
Copy link
Copy Markdown
Collaborator

No description provided.

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request refactors the error handling across the Firebase Admin SDK by introducing a structured ErrorInfo interface and updating various error classes to accept this object. This allows for better inclusion of httpResponse and cause (underlying error) information, improving debuggability. I have provided feedback regarding missing semicolons in auth-api-request.ts and suggested simplifying error messages by removing redundant low-level error details, as these are now captured by the cause property.

);
throw new FirebaseAppError({
code: AppErrorCodes.INVALID_CREDENTIAL,
message: `Failed to parse service account json file: ${(error as Error).message}`,
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Including the low-level error message directly in the main error message string is redundant now that the cause property is available. It's better to keep the main message clean and rely on the cause for the detailed error information. This also avoids potential issues if error is not a standard Error object.

Suggested change
message: `Failed to parse service account json file: ${(error as Error).message}`,
message: 'Failed to parse service account json file.',

throw new FirebaseAppError({
code: AppErrorCodes.INVALID_APP_OPTIONS,
message: `Failed to parse app options file: ${(error as Error).message}`,
cause: error as Error
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the change in credential-internal.ts, it's better to keep the main error message concise and use the cause property to provide the underlying error details.

Suggested change
cause: error as Error
message: 'Failed to parse app options file.',

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant