[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firebase errors are exported as stubs #2582

Open
noahw3 opened this issue May 28, 2024 · 1 comment
Open

Firebase errors are exported as stubs #2582

noahw3 opened this issue May 28, 2024 · 1 comment

Comments

@noahw3
Copy link
noahw3 commented May 28, 2024

[READ] Step 1: Are you in the right place?

  • For issues related to the code in this repository file a Github issue.
  • If the issue pertains to Cloud Firestore, read the instructions in the "Firestore issue"
    template.
  • For general technical questions, post a question on StackOverflow
    with the firebase tag.
  • For general Firebase discussion, use the firebase-talk
    google group.
  • For help troubleshooting your application that does not fall under one
    of the above categories, reach out to the personalized
    Firebase support channel.

[REQUIRED] Step 2: Describe your environment

  • Operating System version: _____
  • Firebase SDK version: 12.1.1
  • Firebase Product: auth
  • Node.js version: _____
  • NPM version: _____

[REQUIRED] Step 3: Describe the problem

Steps to reproduce:

The new error types that are exported in 12.1.1 are great and make error handling much easier. However, the TS interfaces are notably lacking constructors - they just extend all the way to Error. The actual implementations take info: ErrorInfo, message?: string parameters to set the underlying code and message properties.

This means that in testing code I'm not able to really take advantage of the new types without casting or playing other type shenanigans in order to set the properties as expected, which significantly limits the usefulness of these newly exported types.

Relevant Code:

// In a node REPL

> let err = new FirebaseAuthError("test error message")
undefined
> err.code
'auth/undefined'
> err.message
undefined

> let err2 = new FirebaseAuthError({ message: "test error 2", code: "val"  })
undefined
> err2.code
'auth/val'
> err2.message
'test error 2'

// In typescript
// Argument of type '{ message: string; code: string; }' is not assignable to parameter of type 'string'.
const error = new FirebaseAuthError({ message: "test error 2", code: "val"  });

Relates to #2549

@lahirumaramba
Copy link
Member
lahirumaramba commented May 29, 2024

Hey @noahw3, thanks for reporting this! We need a complete error handling revamp in the SDK, but since that was not currently in the roadmap we merged #2549 as a stopgap. The constructors are currently marked as private... I will look into this issue to see what else we can to do improve the exposed error types

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

No branches or pull requests

3 participants