Background
Error handling in PowerShell is extremely messy, by far the primary complaint I have heard about the language, and has actually been cited as a reason to not use PowerShell. The two major complaints I've heard about error handling are:
Current behavior
When running a binary command in PowerShell (ex: git) and the binary errors, the command does not always output an error (neither terminating nor non-terminating). PowerShell clearly detects that the command fails and correctly populates $?, but does not integrate with normal error handling mechanisms. The result is this cumbersome syntax:
git checkout -b master
if (-not $?) {
throw "Command failed"
}
Summary of the new feature/enhancement
If a command sets $? to $false, then the command should write an error to the error stream.
Background
Error handling in PowerShell is extremely messy, by far the primary complaint I have heard about the language, and has actually been cited as a reason to not use PowerShell. The two major complaints I've heard about error handling are:
Current behavior
When running a binary command in PowerShell (ex:
git) and the binary errors, the command does not always output an error (neither terminating nor non-terminating). PowerShell clearly detects that the command fails and correctly populates$?, but does not integrate with normal error handling mechanisms. The result is this cumbersome syntax:Summary of the new feature/enhancement
If a command sets
$?to$false, then the command should write an error to the error stream.