Skip to content

Commit e91b031

Browse files
milanholemansgautamdsheth
authored andcommitted
Fixed group not found error
1 parent c6c63f7 commit e91b031

File tree

1 file changed

+16
-12
lines changed

1 file changed

+16
-12
lines changed

src/Commands/Taxonomy/SetTermGroup.cs

+16-12
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
using System;
2-
using System.Linq.Expressions;
3-
using System.Management.Automation;
4-
using System.Security.Cryptography;
5-
using Microsoft.SharePoint.Client;
1+
using Microsoft.SharePoint.Client;
62
using Microsoft.SharePoint.Client.Taxonomy;
7-
83
using PnP.PowerShell.Commands.Base.PipeBinds;
4+
using System;
5+
using System.Management.Automation;
96

107
namespace PnP.PowerShell.Commands.Taxonomy
118
{
@@ -41,12 +38,19 @@ protected override void ExecuteCmdlet()
4138
if (termStore != null)
4239
{
4340
var group = Identity.GetGroup(termStore);
44-
ClientContext.Load(group);
45-
ClientContext.ExecuteQueryRetry();
41+
try
42+
{
43+
ClientContext.Load(group);
44+
ClientContext.ExecuteQueryRetry();
45+
}
46+
catch (Exception)
47+
{
48+
throw new PSArgumentException("Group not found");
49+
}
4650

47-
if (group.ServerObjectIsNull.Value != false)
51+
try
4852
{
49-
bool updateRequired = false;
53+
var updateRequired = false;
5054
if (ParameterSpecified(nameof(Name)))
5155
{
5256
group.Name = Name;
@@ -64,9 +68,9 @@ protected override void ExecuteCmdlet()
6468
}
6569
WriteObject(group);
6670
}
67-
else
71+
catch (Exception e)
6872
{
69-
throw new PSArgumentException("Group not found");
73+
throw new PSArgumentException(e.Message);
7074
}
7175
}
7276
}

0 commit comments

Comments
 (0)