Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

supply JSON object for authentication error handling #386

Open
abhayastudios opened this issue Jun 7, 2017 · 4 comments
Open

supply JSON object for authentication error handling #386

abhayastudios opened this issue Jun 7, 2017 · 4 comments

Comments

@abhayastudios
Copy link
Contributor

abhayastudios commented Jun 7, 2017

Hi Eddy,

Is there a reason why you return only the error message instead of a JSON object so that an app can have cleaner/better error handling?

For example, at this line, I would return the error.userInfo instead of error.localizedDescription:

userInfo: {
	    NSLocalizedDescription = "The email address is already in use by another account.";
	    "error_name" = "ERROR_EMAIL_ALREADY_IN_USE";
	}

If you are on-board with this I can submit a PR with some changes and maybe support backward compatibility by adding a boolean returnJson parameter to relevant functions that defaults to false.

What do you say?

@EddyVerbruggen
Copy link
Owner

Hi! I don't mind changing that to an object. Perhaps we can use a generic FirebaseError type for all errors?:

export interface FirebaseError {
  code: number; // fi. on iOS error.code (if set)
  message: string; // fi. on iOS error.localizedDescription
  ios: any; // NSError
  android: any
}

@lukasz-galka
Copy link

Any update on that? I would like to check error code from https://firebase.google.com/docs/reference/js/firebase.auth.Auth#createUserWithEmailAndPassword and show proper error message to user.

@EddyVerbruggen
Copy link
Owner

That's the JS doc. Not sure their native SDK errorcodes align with the JS errorcodes.

@zurielrangel
Copy link

I'm working in an app for spanish speakers, how should I handle error messages? :c #help

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

No branches or pull requests

4 participants