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

[Bug]: CapacitorException.code should be of type string #7633

Open
3 tasks done
robingenz opened this issue Aug 29, 2024 · 0 comments
Open
3 tasks done

[Bug]: CapacitorException.code should be of type string #7633

robingenz opened this issue Aug 29, 2024 · 0 comments
Labels

Comments

@robingenz
Copy link
Contributor

Capacitor Version

💊 Capacitor Doctor 💊

Latest Dependencies:

@capacitor/cli: 6.1.2
@capacitor/core: 6.1.2
@capacitor/android: 6.1.2
@capacitor/ios: 6.1.2

Installed Dependencies:

@capacitor/cli: 6.0.0
@capacitor/core: 6.0.0
@capacitor/android: 6.0.0
@capacitor/ios: 6.0.0

[success] iOS looking great! 👌
[success] Android looking great! 👌

Other API Details

No response

Platforms Affected

  • iOS
  • Android
  • Web

Current Behavior

The Capacitor Android/iOS SDK allow rejecting a call with a code of type string, see:

public void reject(String msg, String code, Exception ex) {

However, the type of the code property of the CapacitorException class only allows values of type ExceptionCode, see:

readonly code?: ExceptionCode,

For example, the Capacitor Firebase Authnentication plugin uses the code property to forward the error code from the Firebase SDK to the WebView in addition to the error message. Currently a typecast has to be used to get the correct type of the property:

private getMessageFromCapacitorException(error: CapacitorException): string {
    switch (error.code as string) {
      case 'email-already-in-use': {
        return this.translocoService.translate(
          'core.message.error.firebase.auth.emailAlreadyInUse',
        );
      }
      ...
    }
  }

Expected Behavior

The type of the code property should be of type CapacitorException | string.

Project Reproduction

https://github.com/robingenz/capacitor-firebase-authentication-demo

Additional Information

No response

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

No branches or pull requests

1 participant