Quantcast
Channel: Visual C# forum
Viewing all articles
Browse latest Browse all 31927

Help w/ code review

$
0
0

I understand that we should reserve try/catch for those cases where errors are unpredictable. However, in my case, SharePoint does not provide a good API to detect whether an SPGroup object exists or not, hence, I am using try/catch.

In the below code, I may get an exception in some cases while creating adminGroup object. However, this entire code block is a value-added service and I do not want end user to be neither interrupted nor notified about this exception. Is this a good way of handling the situation with an empty catch?

try
{
   SPGroup adminGroup = web.SiteGroups[groupTitle];
   if (!adminGroup.AllowMembersEditMembership)
     {
        adminGroup.AllowMembersEditMembership = true;
        adminGroup.Update();
     }
}
catch
{                                   
}       





Viewing all articles
Browse latest Browse all 31927

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>