Skip to content

Commit

Permalink
add error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
JohnDuprey committed Feb 12, 2025
1 parent bc714f4 commit 16f226f
Showing 1 changed file with 12 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,12 @@ function Invoke-ExecGitHubAction {
$Results = @(Get-GitHubBranch @SplatParams)
}
'GetOrgs' {
$Orgs = Invoke-GitHubApiRequest -Path 'user/orgs'
$Results = @($Orgs)
try {
$Orgs = Invoke-GitHubApiRequest -Path 'user/orgs'
$Results = @($Orgs)
} catch {
$Results = 'You may not have permission to view organizations, check your PAT scopes and try again - {0}' -f $_.Exception.Message
}
}
'GetFileTree' {
$Files = (Get-GitHubFileTree @SplatParams).tree | Where-Object { $_.path -match '.json$' } | Select-Object *, @{n = 'html_url'; e = { "https://github.com/$($SplatParams.FullName)/tree/$($SplatParams.Branch)/$($_.path)" } }
Expand All @@ -54,7 +58,12 @@ function Invoke-ExecGitHubAction {
$Results = Import-CommunityTemplate @SplatParams
}
'CreateRepo' {
$Repo = New-GitHubRepo @SplatParams
try {
$Repo = New-GitHubRepo @SplatParams
} catch {
$Results = 'You may not have permission to create repositories, check your PAT scopes and try again - {0}' -f $_.Exception.Message
break
}
if ($Results.id) {
$Table = Get-CIPPTable -TableName CommunityRepos
$RepoEntity = @{
Expand Down

0 comments on commit 16f226f

Please sign in to comment.