Created
January 24, 2017 15:26
-
-
Save CosmosKey/2decc69c880a1e99502d5a46ca63e484 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
New-Module -Name tt -ScriptBlock { | |
$ErrorActionPreference="stop" | |
function t1 { | |
[CmdletBinding()] | |
param() | |
try { | |
"trying" | |
Get-Content c:\TheFileWhichDoesNotExist.txt | |
"Yiiihaaaa" | |
} catch { | |
$err = [System.Management.Automation.ErrorRecord]::new($_.Exception,"myErr",$_.CategoryInfo.Category,$null) | |
$PSCmdlet.WriteError($err) | |
} | |
} | |
} | Import-Module | |
t1 # implicit -EA=stop due to the EA preference set in the module above | |
t1 -ErrorAction SilentlyContinue |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment