Search notes:

PowerShell: error handling

Terminating and non-terminating errors

PowerShell distinguishes between terminating and non-terminating errors.
A terminating error immediately terminates the current pipeline.
Non-terminating errors are typically reported, but the cmdlet (and hence the pipeline) continues processing its input objects.
Terminating errors are raised by calling the method ThrowTerminatingError of the class System.Management.Automation.Cmdlet.
A cmdlet reports a non-terminating error by calling WriteError(), which then sends an error record to the error stream.
Such an error record is described by an instance of System.Management.Automation.ErrorRecord.
The preference variable $errorActionPreference controls how PowerShell reacts to a non-terminating error.

See also

https://github.com/MicrosoftDocs/PowerShell-Docs/issues/1583
The statements
The automatic variable $error.
The $errorActionPreference preference variable.
The write-error cmdLet.
The System.Management.Automation.ErrorCategory enum.

Links

An Introduction to Error Handling in PowerShell

Index