PowerShell 5.1
I've written a wrapper script that launches another script, logs its output (via Start-Transcript), sends an email if it exited with a non-zero code, and finally rotates the log file based on file size.
I only want to catch errors that would cause the called script to exit when executed on its own. (Script-terminating term based on the discussion here: https://github.com/MicrosoftDocs/PowerShell-Docs/issues/1583).
try { 
    Invoke-Expression "& '$Script' $ArgList"
    $err = $LastExitCode
} catch { 
    Write-Error -ErrorRecord $_
    $err = 1
}
Catch this:
$ErrorActionPreference = 'Stop'
Remove-Item -Path DoesntExist
or this:
throw "Error"
But not this (script should continue executing as it would if not called via the logging script):
Test-Path -Foo bar
Is it possible? Or is there a better approach?