Catch user already registered Godot

Hi all, I’m trying to catch if user is already registered to the database.
I understand this has been answered here: How should I check if an account already exists to decide if the user should register or login? - Heroic Labs

But godot does not handle exceptions, and that’s not an error to go through the is_exception handler.

I see that the Session returns the values from here:

func _to_string():
	if is_exception():
		return get_exception()._to_string()
	return "Session<created=%s, token=%s, create_time=%d, username=%s, user_id=%s, vars=%s, expire_time=%d, refresh_token=%s refresh_expire_time=%d>" % [
		created, token, create_time, username, user_id, str(vars), expire_time, refresh_token, refresh_expire_time]

The way fthings are for now per docs are:

print("Successfully authenticated: %s" % session)

I’m trying for example to first just print that single variable form that return, but haven’t been able so far.

How should I catch that created bool and handle if user is already registered?
Also, in a side note, is there a place where I can get a list of possible errors and codes to handle them accordingly?

Thanks!

EDIT:

Sorry, I have tried this before but it was throwing an error, I have no idea why I tried again and it worked.
As simple as:

if !session.created:
			print("User already registered")

Thanks for sharing your solution.

1 Like