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

Fatal error: Uncaught PDOException: SQLSTATE[HY000]: General error: 8 attempt to write a readonly database in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php:78 Stack trace: #0 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(78): PDOStatement->execute(Array) #1 /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php(30): insert_webrequest_('/notes/Windows/...', 1758193862, '216.73.216.150', 'Mozilla/5.0 App...', NULL) #2 /home/httpd/vhosts/renenyffenegger.ch/httpsdocs/notes/Windows/PowerShell/language/error-handling/index(79): insert_webrequest() #3 {main} thrown in /home/httpd/vhosts/renenyffenegger.ch/php/web-request-database.php on line 78