-
Notifications
You must be signed in to change notification settings - Fork 352
Description
I am using the new sdk version 3.0
When I catch the error raised by FirebaseError, I find some inconsistence on how the errors are handled and provided.
For Example using an already registered account ( let's say jendoe@gmail.com) in my project, I find:
- Creating a user
I use auth.create_user with the right parameters, and I get an error with:
print(str(error)) -> Error while calling Auth service (EMAIL_EXISTS).
print(error.code) -> INVALID_ARGUMENT
print(error.cause) -> 400 Client Error: Bad Request for url: https://identitytoolkit.googleapis.com/v1/projects/xxxxxx/accounts
print(type(error)) -> <class 'firebase_admin.exceptions.InvalidArgumentError'>
print(error.http_response.json()) -> {'error': {'code': 400, 'message': 'EMAIL_EXISTS', 'errors': [{'message': 'EMAIL_EXISTS', 'domain': 'global', 'reason': 'invalid'}]}}
- Getting a user by email
I use auth.get_user_by_email with the right parameter, and I get an error with:
print(str(error)) -> No user record found for the provided email: jendoe@gmail.com.
print(error.code) -> NOT_FOUND
print(error.cause) -> None
print(type(error)) -> <class 'firebase_admin._auth_utils.UserNotFoundError'>
print(error.http_response.json()) -> {'kind': 'identitytoolkit#GetAccountInfoResponse'}
the two error are kind of inconsistent in my opinion. There should be consistence in the fields, in order to be consistent with the overall idea of having a global FirebaseError in the exception.
In particular, the create method has the old format, and I cannot understand where the 'message': 'EMAIL_EXISTS' comes from (I looked the whole source code).
Would be nice if all the errors (Exception) would follow the same structure, this would allow to perform many things in an easy way without polluting the code in an app.
What do you think @hiranya911 ??
Thanks for the great work...