Skip to content

Commit c64a5e9

Browse files
committed
add import error handling and output
1 parent f2e3478 commit c64a5e9

1 file changed

Lines changed: 14 additions & 2 deletions

File tree

Modules/CIPPCore/Public/Entrypoints/HTTP Functions/Tools/GitHub/Invoke-ExecCommunityRepo.ps1

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,20 @@ function Invoke-ExecCommunityRepo {
160160
$Path = $Request.Body.Path
161161
$FullName = $Request.Body.FullName
162162
$Branch = $Request.Body.Branch
163-
$Template = Get-GitHubFileContents -FullName $FullName -Path $Path -Branch $Branch
164-
Import-CommunityTemplate -Template $Template.content -SHA $Template.sha
163+
try {
164+
$Template = Get-GitHubFileContents -FullName $FullName -Path $Path -Branch $Branch
165+
$Content = $Template.content | ConvertFrom-Json
166+
Import-CommunityTemplate -Template $Content -SHA $Template.sha
167+
$Results = @{
168+
resultText = 'Template imported'
169+
state = 'success'
170+
}
171+
} catch {
172+
$Results = @{
173+
resultText = "Error importing template: $($_.Exception.Message)"
174+
state = 'error'
175+
}
176+
}
165177
}
166178
default {
167179
$Results = @{

0 commit comments

Comments
 (0)