Skip to content

Commit 35f61ef

Browse files
CopilotKoenZomers
andcommitted
Address code review feedback: wrap cleanup in try-catch and use InvalidOperationException
Co-authored-by: KoenZomers <[email protected]>
1 parent 79919ad commit 35f61ef

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

src/Commands/Apps/AddApp.cs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,14 @@ private void AddPnPApp()
126126
// Handle the specific CSPConfig error when deploying to site collection app catalog
127127
// This is a known SharePoint service-side limitation where tenant-level script sources
128128
// are incorrectly included in site-level CSP validation
129-
manager.Remove(result, Scope);
129+
try
130+
{
131+
manager.Remove(result, Scope);
132+
}
133+
catch
134+
{
135+
// If cleanup fails, continue to throw the original error message
136+
}
130137

131138
var errorMessage = "Failed to deploy the app due to a SharePoint limitation. " +
132139
"The error 'Value of: [CSPConfig] cannot exceed: [100000]' occurs when there are too many " +
@@ -140,7 +147,7 @@ private void AddPnPApp()
140147
"- https://github.com/SharePoint/sp-dev-docs/issues/10412\n" +
141148
"- https://github.com/SharePoint/sp-dev-docs/issues/10369";
142149

143-
throw new Exception(errorMessage, ex);
150+
throw new InvalidOperationException(errorMessage, ex);
144151
}
145152
catch
146153
{

src/Commands/Apps/PublishApp.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ private void PublishPnPApp()
112112
"- https://github.com/SharePoint/sp-dev-docs/issues/10412\n" +
113113
"- https://github.com/SharePoint/sp-dev-docs/issues/10369";
114114

115-
throw new Exception(errorMessage, ex);
115+
throw new InvalidOperationException(errorMessage, ex);
116116
}
117117
}
118118
else

0 commit comments

Comments
 (0)