API
Version 7.x > API > return type for CMS.SiteProvider.UserInfoProvider.SetUserInfo(user); View modes: 
User avatar
Member
Member
jeff.thompson-io-dev - 10/3/2012 3:13:20 PM
   
return type for CMS.SiteProvider.UserInfoProvider.SetUserInfo(user);
So, I am customizing a method that creates a new user from data provided from a different website. The issue that I am having is that I want to return a boolean value whether or not the user was created. The method I use to create the user is:

CMS.SiteProvider.UserInfoProvider.SetUserInfo(user);

Does this method have a boolean return type or is it void?

I have looked in many places online but could not find the answer to this question. Any insight would be appreciated. Thanks.

User avatar
Member
Member
jeff.thompson-io-dev - 10/3/2012 3:43:26 PM
   
RE:return type for CMS.SiteProvider.UserInfoProvider.SetUserInfo(user);
Never mind. I figured it out. It doesn't return anything. It would be nice if it returned a Boolean though.

User avatar
Kentico Support
Kentico Support
kentico_radekm - 10/4/2012 6:27:54 AM
   
RE:return type for CMS.SiteProvider.UserInfoProvider.SetUserInfo(user);
Hello.

Yes, it is defined as void so it has no return value defined. However, if the method fails from some reason (imagine it as 'false' result), some exception should be raised, so you are notified about it. If you mean some particular scenario this bool return value could be used for, please describe. Thank you.

Best Regards,
Radek Macalik

User avatar
Guest
nicolas.juteau-nexun - 10/4/2012 9:01:29 AM
   
RE:return type for CMS.SiteProvider.UserInfoProvider.SetUserInfo(user);
Hi Jeff,

As an alternative method, you could evaluate if user.UserIDis different than 0 after the call to UserInfoProvider.SetUserInfo(user).

However, like Radek just said, the best way for you to handle errors (and therefore know what went wrong) is enclosing the call into a try catch, then take the appropriate action depending on which exception is raised.

Cheers,
Nicolas