Problem with CurrentUser

Hi,
I am trying to cast the CurrentUser to a more specific User class which has implementations of getters and setters of other properties within the User class like this:

User user = (User)Backendless.UserService.CurrentUser();

Where User extends BackendlessUser. However this is giving me the following error:
BackendlessException{ code: ‘Internal client exception’, message: ‘null’ }
Can you explain why this is happening please?
Thanks.

Hi Victor,

Subclassing BackendlessUser is not a good idea. The case you showed would not work as the underlying instance knows nothing about your “User” class.

Also, could you please narrow down where BackendlessException is thrown from? I do not think the line you showed could result in that exception. Possibly, double-check that you do not use synchronous calls on the main UI thread.

Regards,
Mark

I just followed the example downloaded from the code generator from the developer console and extended the BackendlessUser class. So what is the best structured way to obtain property values from the BackendlessUser entity other than email password and id.

Use the getProperty method:

You can get all the properties with getProperties()

Regards,
Mark