diff --git a/samy.ps1 b/samy.ps1 index 06d5287..3c95701 100644 --- a/samy.ps1 +++ b/samy.ps1 @@ -139,12 +139,21 @@ $chunks = @( foreach ($c in $chunks) { - $content = Import-SamyChunk -Url $c.Url -Name $c.Name - . ([ScriptBlock]::Create($content)) - Write-Host "[Success] Loaded: $($c.Name)" -ForegroundColor Green + try { + $content = Import-SamyChunk -Url $c.Url -Name $c.Name -ErrorAction Stop + . ([ScriptBlock]::Create($content)) + Write-Host "[Success] $($c.Name)" -ForegroundColor Green + } + catch { + $msg = $_.Exception.Message + if ([string]::IsNullOrWhiteSpace($msg)) { $msg = "$_" } + Write-Host "[Failed] $($c.Name): $msg" -ForegroundColor Red + throw # or continue + } } + if (-not (Get-Command Invoke-ScriptAutomationMonkey -ErrorAction SilentlyContinue)) { throw "Bootstrap loaded chunks, but Invoke-ScriptAutomationMonkey was not found. Ensure src/core.ps1 defines it." }