Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ERR-01 and ERR-02 implies that you know all commands #74

Open
paalbra opened this issue Nov 8, 2016 · 0 comments
Open

ERR-01 and ERR-02 implies that you know all commands #74

paalbra opened this issue Nov 8, 2016 · 0 comments

Comments

@paalbra
Copy link

paalbra commented Nov 8, 2016

In ERR-01 and ERR-02 you're told to use -ErrorAction on all cmdlets and set ErrorActionPreference around everything else, where needed.

This leaves it to the scripter to figure out how every command emits its errors and how they're emitted. I believe this is impossible.

Personally I put this in the first two lines of the begin block in every advanced function I create:

Set-StrictMode -Version "Latest"
Set-Variable -Name "ErrorActionPreference" -Scope "Script" -Value "Stop"

With these two lines you will fail fast, hard and consistently (the users ErrorActionPreference will not matter).

I write Python quite often and would like to quote parts of The Zen of Python:

Errors should never pass silently.
Unless explicitly silenced.

I believe any PowerShell script also should behave this way. Silent errors can and will lead to nothing but confusion and frustrating debug situations.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant